From a3d0a0250a0d7f7675113af8781fa2448cbef93e Mon Sep 17 00:00:00 2001 From: Jay Lee Date: Thu, 31 Dec 2015 08:52:05 -0500 Subject: [PATCH 1/3] Remove usage of oauth2 API for now as it's nearly useless --- src/gam.py | 32 ++------------------------------ 1 file changed, 2 insertions(+), 30 deletions(-) diff --git a/src/gam.py b/src/gam.py index e0c4ede0..0a068edb 100755 --- a/src/gam.py +++ b/src/gam.py @@ -765,7 +765,6 @@ API_VER_MAPPING = { u'gmail': u'v1', u'groupssettings': u'v1', u'licensing': u'v1', - u'oauth2': u'v2', u'reports': u'reports_v1', u'siteVerification': u'v1', u'email-settings': u'v1', @@ -8684,34 +8683,8 @@ def getUsersToModify(entity_type=None, entity=None, silent=False, return_uids=Fa return full_users def OAuthInfo(): - if len(sys.argv) > 3: - access_token = sys.argv[3] - else: - storage = oauth2client.file.Storage(GC_Values[GC_OAUTH2_TXT]) - credentials = storage.get() - if credentials is None or credentials.invalid: - doRequestOAuth() - credentials = storage.get() - credentials.user_agent = GAM_INFO - http = httplib2.Http(disable_ssl_certificate_validation=GC_Values[GC_NO_VERIFY_SSL]) - if credentials.access_token_expired: - credentials.refresh(http) - access_token = credentials.access_token - print u"\nOAuth File: %s" % GC_Values[GC_OAUTH2_TXT] - oa2 = buildGAPIObject(u'oauth2') - token_info = callGAPI(oa2, u'tokeninfo', access_token=access_token) - print u"Client ID: %s" % token_info[u'issued_to'] - try: - print u"Secret: %s" % credentials.client_secret - except UnboundLocalError: - pass - print u'Scopes:' - for scope in token_info[u'scope'].split(u' '): - print u' %s' % scope - try: - print u'Google Apps Admin: %s' % token_info[u'email'] - except KeyError: - print u'Google Apps Admin: Unknown' + # TODO eventually would be good if this did something to test admin-selected scopes + pass def select_default_scopes(all_apis): for api_name, api in all_apis.items(): @@ -8740,7 +8713,6 @@ def select_default_scopes(all_apis): def doRequestOAuth(): admin_email = raw_input(u'Please enter your admin email address: ') apis = API_VER_MAPPING.keys() - apis.remove(u'oauth2') all_apis = {} for api in apis: version = getAPIVer(api) From 433cdfe87dfc4401c9c85f898800a1de2de63adc Mon Sep 17 00:00:00 2001 From: Jay Lee Date: Thu, 31 Dec 2015 08:57:16 -0500 Subject: [PATCH 2/3] define UBER_SCOPES to cut down on unnecessary scope overlap --- src/gam.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/gam.py b/src/gam.py index 0a068edb..920e86de 100755 --- a/src/gam.py +++ b/src/gam.py @@ -8686,8 +8686,16 @@ def OAuthInfo(): # TODO eventually would be good if this did something to test admin-selected scopes pass +UBER_SCOPES = { + u'gmail-v1': [u'https://mail.google.com/'], + u'drive-v2': [u'https://www.googleapis.com/auth/drive'] + } + def select_default_scopes(all_apis): for api_name, api in all_apis.items(): + if api_name in UBER_SCOPES.keys(): + all_apis[api_name][u'use_scopes'] = UBER_SCOPES[api_name] + continue all_apis[api_name][u'use_scopes'] = [] scopes = api[u'auth'][u'oauth2'][u'scopes'].keys() if len(scopes) == 1: From 16add1bf241ca3d17b31032a047e99340073a0b8 Mon Sep 17 00:00:00 2001 From: Jay Lee Date: Thu, 31 Dec 2015 09:34:03 -0500 Subject: [PATCH 3/3] UBER_SCOPE for appsactivity-v1 API --- src/gam.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gam.py b/src/gam.py index 920e86de..d93d3452 100755 --- a/src/gam.py +++ b/src/gam.py @@ -8688,7 +8688,8 @@ def OAuthInfo(): UBER_SCOPES = { u'gmail-v1': [u'https://mail.google.com/'], - u'drive-v2': [u'https://www.googleapis.com/auth/drive'] + u'drive-v2': [u'https://www.googleapis.com/auth/drive'], + u'appsactivity-v1': [u'https://www.googleapis.com/auth/activity'] } def select_default_scopes(all_apis):