MCPcopy Create free account
hub / github.com/geekcomputers/Python / get_credentials

Function get_credentials

sendemail.py:19–34  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

17CLIENT_SECRET_FILE = "client_secret.json"
18APPLICATION_NAME = "Gmail API Python Send Email"
19def get_credentials():
20 home_dir = os.path.expanduser("~")
21 credential_dir = os.path.join(home_dir, ".credentials")
22 if not os.path.exists(credential_dir):
23 os.makedirs(credential_dir)
24 credential_path = os.path.join(credential_dir, "gmail-python-email-send.json")
25 store = oauth2client.file.Storage(credential_path)
26 credentials = store.get()
27 if not credentials or credentials.invalid:
28 flow = client.flow_from_clientsecrets(CLIENT_SECRET_FILE, SCOPES)
29 flow.user_agent = APPLICATION_NAME
30 credentials = tools.run_flow(flow, store)
31
32 print("Storing credentials to " + credential_path)
33
34 return credentials
35
36
37def SendMessage(sender, to, subject, msgHtml, msgPlain, attachmentFile=None):

Callers 1

SendMessageFunction · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected