Sunday, 5 March 2023

I am getting Access blocked error while trying to get athentication code which i will use to get refresh token?

here is what is tried I changed the status of O Auth Consent screen from testing to publish and the app scope is external then i created the O Auth client Id token and then i tried this code but this is giving error when i try to authenticate to the app.

from google.oauth2.credentials import Credentials
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request

SCOPES = ['https://www.googleapis.com/auth/drive']

CLIENT_SECRETS_FILE = 'client.json'

REDIRECT_URI = 'urn:ietf:wg:oauth:2.0:oob'
flow = InstalledAppFlow.from_client_secrets_file(CLIENT_SECRETS_FILE, SCOPES, redirect_uri=REDIRECT_URI)
auth_url, _ = flow.authorization_url(prompt='consent')
print(f'Please go to this URL to authorize the application: {auth_url}')
auth_code = input('Enter the authorization code: ')
flow.fetch_token(code=auth_code)
creds = flow.credentials
print(f'Access token: {creds.token}')
print(f'Refresh token: {creds.refresh_token}')

Can you spot how to do it in python and solve this error.



from I am getting Access blocked error while trying to get athentication code which i will use to get refresh token?

No comments:

Post a Comment