[Python] Can't authenticate when using Gmail API

Discussão em 'Python' iniciado por Stack, Abril 16, 2025.

  1. Stack

    Stack Membro Participativo

    Can't authenticate Gmail API no matter what I try. Using python.

    I set up proper python code and I get

    "Google hasn’t verified this app You’ve been given access to an app that’s currently being tested. You should only continue if you know that invited you."

    then i click continue, and then i get:

    "Something went wrong Sorry, something went wrong there. Try again."

    I've tried removing all 2 step authentication.

    //

    >! import statements

    SCOPES = ['https://www.googleapis.com/auth/gmail.settings.basic',
    'https://www.googleapis.com/auth/gmail.readonly'
    ]

    flow = InstalledAppFlow.from_client_secrets_file(
    r'my_correct_path_to_secret_file'
    , scopes=['https://www.googleapis.com/auth/gmail.readonly'])
    creds = flow.run_local_server(port=0)

    >! Save the credentials for the next run
    with open('token.json', 'w') as token:
    token.write(creds.to_json())

    >! Create the Gmail API client
    gmail_service = build('gmail', 'v1', credentials=creds)

    Continue reading...

Compartilhe esta Página