Skip to content

Alternative for generate_oauth2_token in gmail_oauth2 (OOB DEPRECATION) #17

Description

@angelo-francisco

This script (gmail_oauth2.py) is using OOB that it's beeing used was discontinued
(REDIRECT_URI = 'urn:ietf:wg:oauth:2.0:oob'). I created a script that generates de the token and the refresh token using google modern recommendations:

from google_auth_oauthlib.flow import InstalledAppFlow

SCOPES = ["https://mail.google.com/"]

credentials_path = input("CREDENTIALS_PATH: ")

flow = InstalledAppFlow.from_client_secrets_file(
    credentials_path, # your credentials file from google, download it from gcp
    SCOPES
)

creds = flow.run_local_server(port=8088)

print("TOKEN: ", creds.token)
print("REFRESH: ", creds.refresh_token)

I know it isn't too flexible for changes it is useful for who wants speed. I'm open for contributions. And hope this to help who get in google OOB issues.

Maybe after i'll make a pull request implementing this code as a functionality in gmail_oauth2.py script and with an upgraded readme.md.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions