2

I have a YouTube class which uploads a video on YouTube using a OAuth authentication. When I tested it on my local workspace, it worked fine but opened a browser asking if the access to my YouTube channel is permitted.

Now, my class should work on a server. There is no browser which can open and that's the problem. Everything works up to this point.

Does anybody have an idea how I could redirekt/avoid or do anything else with this browser window?

Thanks a lot for your help! Best wishes.

3
  • Without a browser you cant authenticate it. Assuming that you will always be uploading to your own account you can authenticate it on your local machine and move the refresh token over to the server with out a browser it will work there as well. Commented Apr 19, 2016 at 6:57
  • Great! That's just what I imagined! Question: Where do I get the refresh token and how do I use it? Commented Apr 19, 2016 at 7:27
  • That would depend upon your code when you request access on your local machine a refresh token is returned when you authenticate. You should have it someplace. You just need to get your code to load a stored one. You will need to post some code though before we can help you more. Commented Apr 19, 2016 at 7:38

2 Answers 2

3

If you want to submit a video on behalf of an user, the user has to authenticate and authorize the application somewhere. (if you are using the v3 API)

There are flows which will work with an server-side application, though:

https://developers.google.com/youtube/v3/guides/moving_to_oauth#using-oauth-20-for-server-side-standalone-scripts

https://developers.google.com/youtube/v3/guides/auth/server-side-web-apps#Obtaining_Access_Tokens

Sign up to request clarification or add additional context in comments.

Comments

2

thank you for your help!

The solution of my problem was to authenticate the access on my local browser and to copy the stored token to the server.

Best wishes!

2 Comments

Any chance you could share where this token-file is located and if it expires or not? Maybe some YouTube documentation links (if any) as well? I guess it is this one : C:\Users\User\AppData\Roaming\Google.Apis.Auth\Google.Apis.Auth.OAuth2.Responses.TokenResponse-user ?
Hi! :-) In the code you can define a path where the token will be saved or looked up. When I remember right, the token will be renewed every time you make an API call. Here is the link where I got my code from: developers.google.com/youtube/v3/code_samples/… Best wishes!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.