mirror of
https://github.com/valitydev/Cortex-Analyzers.git
synced 2024-11-06 09:05:19 +00:00
deleted testing file
This commit is contained in:
parent
eef66ba6f5
commit
127f29cabc
@ -1,37 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from google.oauth2 import service_account
|
||||
|
||||
scopes = [
|
||||
"https://mail.google.com/",
|
||||
"https://www.googleapis.com/auth/gmail.settings.basic",
|
||||
]
|
||||
subject = "thedelegatedemail@gmail.com"
|
||||
def authenticate(service_account_file, scopes, subject):
|
||||
"""Peforms OAuth2 auth for a given service account, scope and a delegated subject
|
||||
|
||||
Args:
|
||||
service_account_file (str): Path to the service account file
|
||||
scopes (array): array of oauth2 scopes needed to operate
|
||||
subject (str): email adress of the user, whos data shall be accessed (delegation)
|
||||
|
||||
Returns:
|
||||
google.auth.service_account.Credentials if valid otherwise None
|
||||
"""
|
||||
credentials = service_account.Credentials.from_service_account_file(
|
||||
service_account_file,
|
||||
scopes=scopes,
|
||||
subject=subject
|
||||
)
|
||||
|
||||
if (credentials.valid) and (credentials.has_scopes(scopes)):
|
||||
return credentials
|
||||
else:
|
||||
return None
|
||||
|
||||
check = authenticate("/path/to/service_account.json", scopes, subject)
|
||||
|
||||
if (check is not None):
|
||||
print("Authentication worked")
|
||||
else:
|
||||
print(check)
|
Loading…
Reference in New Issue
Block a user