Last active
March 15, 2025 13:20
-
-
Save proffapt/adbc716a427c036f238e828d8995e1a3 to your computer and use it in GitHub Desktop.
Script to generate `token.json` from `credentials.json` file for gmail enabled google api
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from google_auth_oauthlib.flow import InstalledAppFlow | |
scopes = [f"https://www.googleapis.com/auth/gmail.{sys.argv[1]}"] | |
flow = InstalledAppFlow.from_client_secrets_file("credentials.json", scopes) | |
creds = flow.run_local_server(port=0) | |
with open("token.json", "w") as token: | |
token.write(creds.to_json()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment