Hi,
I am trying to generate YouTube OAuth Refresh Tokens that never expire. Our Youtube application is currently in production, however, when we tried to generate the token by using the following python script and open the verification link in our browser to get authorization code manually, we have received Access blocked Error 400: invalid_request. This script works successfully if I change my application to TESTING mode.
flow = InstalledAppFlow.from_client_secrets_file(
"youtube/secrets.json", youtube_scopes)
)
creds = flow.run_console()
For my understanding, I need to change the application status from TESTING to PRODUCTION mode in order to get the refresh tokens that never expire. Do I need to change the
Thank you for your support!
Hi @fcarety,
Welcome to the Google Cloud Community!
Just a heads up, YouTube isn’t technically considered part of the Google Cloud product lineup, so I suggest reposting your question on the YouTube community or on Stack Overflow with the youtube-api, youtube-data-api, and youtube-v3-api tags instead.
OAuth 2.0 has short-lived tokens and long-lived tokens. For your specific use case, you’d want to use a long-lived refresh token. To learn how to generate a long-lived refresh token for your application, follow this guide from the YouTube developer site.
Your application could encounter an error due to several possible reasons. Refer to the list of descriptions for the error code 400 for more information.
If you need more assistance with your application, follow these OAuth 2.0 flows based on your use case. You may also check out our code snippets for Python for more examples.
I hope this helps!