From 127f29cabc174f45383e2e573973ae7ed627e0da Mon Sep 17 00:00:00 2001 From: strassi Date: Wed, 4 Nov 2020 19:07:19 +0100 Subject: [PATCH] deleted testing file --- responders/Gmail/google-test.py | 37 --------------------------------- 1 file changed, 37 deletions(-) delete mode 100644 responders/Gmail/google-test.py diff --git a/responders/Gmail/google-test.py b/responders/Gmail/google-test.py deleted file mode 100644 index 42130ab..0000000 --- a/responders/Gmail/google-test.py +++ /dev/null @@ -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)