Search code examples
youtubegoogle-oauth

Using a single account with OAuth2


I would like to use the YouTube API with a single account (my account) and use it to allow users to make uploads. My original assumption was that I'd be able to generate an access token and then just use that forever, however I believe it is expiring.

Is there a way, with OAuth2, to permanently authenticate a single account? Or is there a way to authenticate a single account via OAuth2 without needing the browser (eg. via remote request(s) on the server)?


Solution

  • Yes, you can create a refresh token for your own account and put that refresh token in the client. The client id you register for this case should be "other"/native client. In this case a secret is not required to get an access token from refresh token.

    Disclaimer: this is not a great use case for OAuth2 and not the best way to do this because once you put a token in a client anyone can take it and post it to the world and everyone will have access to it. So a malicious user could upload c porn into your account and your account could get suspended and may be you will get in legal trouble (because you have no control over who uploads what). Depending on the application, I may be able to suggest a better way.