2
votes

note : i have only 1 account gmail / channel

im creating page index.html for upload video to youtube with this ref : https://developers.google.com/youtube/v3/code_samples/javascript . and running well ..

and the problem is : before uploading video , i must login google for auth .. which is the account is based from my browser ..

question : i need auto login / set email + password. (no prompt from google , because i wanna setting this for upload into 1 same channel / 1 account gmail) for index.html.

so, if PC-A , PC-B or PC-C , access http://example.com/index.html .. they can upload video without login with their accounts.

Thanks.

1

1 Answers

1
votes

For offline access, you can setup a backend server accessible from PC-A, PC-B & PC-C which will store a refresh_token with the scope https://www.googleapis.com/auth/youtube, check this documentation about OAuth2.0 for Web server. You can test with Oauth 2.0 Playground.

This refresh token will be used to request a new access token. With this access token, you can request Google API such as upload video depending on the scope you specified (in this case https://www.googleapis.com/auth/youtube)

Then, you will have 2 options :

  • the client request an access token, the server generates one, and send the access token back to the client browser so that it performs request in client side
  • the client upload video to your server, the server generates an access token (or reuse one) and make the Google API request from server side

Note that the access token periodically expires, when an access token becomes invalid (eg call return status code 401), you have to refresh it, see this