Spaces:
Runtime error
Runtime error
File size: 726 Bytes
0a0e1fc 33ffec6 0a0e1fc 33ffec6 0a0e1fc 33ffec6 0a0e1fc 33ffec6 0a0e1fc 33ffec6 0a0e1fc 33ffec6 0a0e1fc 33ffec6 0a0e1fc 33ffec6 0a0e1fc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | import os
from google_auth_oauthlib.flow import InstalledAppFlow
# Gmail API scope
SCOPES = [
"https://mail.google.com/"
]
def run_authentication():
print("Starting Google OAuth Authentication Flow...")
if not os.path.exists("credentials.json"):
print("ERROR: Please place your 'credentials.json' file in this folder first!")
return
flow = InstalledAppFlow.from_client_secrets_file(
"credentials.json",
SCOPES
)
creds = flow.run_local_server(port=8080)
with open("token.json", "w") as token_file:
token_file.write(creds.to_json())
print("\nSUCCESS: 'token.json' has been created successfully!")
if __name__ == "__main__":
run_authentication() |