From 20bba75e41c3e39ad8ec6ea95c4d9264c5e4bf5b Mon Sep 17 00:00:00 2001 From: Jay Lee Date: Wed, 30 Dec 2015 16:12:49 -0500 Subject: [PATCH 1/2] default scope selections basic logic is: -if 1 scope for API, use it -skip over scopes ending in .readonly, .action or .verify_only UNLESS all scopes are readonly, use all scopes (this is case with reports api) -all other scopes are used by default. --- src/gam.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/gam.py b/src/gam.py index b00f1d73..66dadf4d 100755 --- a/src/gam.py +++ b/src/gam.py @@ -8728,10 +8728,32 @@ def doRequestOAuth(): service = googleapiclient.discovery.build(api, version, http=http, cache_discovery=False) except googleapiclient.errors.UnknownApiNameOrVersion: service = getServiceFromDiscoveryDocument(api, version, http) - all_apis[api] = service._rootDesc + all_apis[u'%s-%s' % (api, version)] = service._rootDesc i = 0 + # Default Scope Selections + for api_name, api in all_apis.items(): + all_apis[api_name][u'use_scopes'] = [] + scopes = api[u'auth'][u'oauth2'][u'scopes'].keys() + if len(scopes) == 1: + all_apis[api_name][u'use_scopes'] += scopes + continue + all_readonly = True + for scope in api[u'auth'][u'oauth2'][u'scopes'].keys(): + if scope.endswith(u'.readonly'): + continue + elif scope.endswith(u'.action'): + all_readonly = False + continue + elif scope.endswith(u'verify_only'): + all_readonly = False + continue + else: + all_apis[api_name][u'use_scopes'].append(scope) + all_readonly = False + if all_readonly: + all_apis[api_name][u'use_scopes'] += scopes for api in all_apis.values(): - print u'[*] %s) %s' % (i, api[u'title']) + print u'[*] %s) %s (%s scopes)' % (i, api[u'title'], len(api[u'use_scopes'])) i += 1 def batch_worker(): From d2039e55668af9cd06b70e43208de2da7aea4a92 Mon Sep 17 00:00:00 2001 From: Jay Lee Date: Wed, 30 Dec 2015 16:24:37 -0500 Subject: [PATCH 2/2] cleanup admin settings API name --- src/admin-settings-v1.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/admin-settings-v1.json b/src/admin-settings-v1.json index 5f75e3cb..c1fa4e6e 100644 --- a/src/admin-settings-v1.json +++ b/src/admin-settings-v1.json @@ -5,7 +5,7 @@ "name": "admin-settings", "version": "v1", "revision": "20130823", - "title": "Admin Settings API (read-only calls)", + "title": "Admin Settings API", "description": "Lets you access Google Apps Admin Settings", "ownerDomain": "google.com", "ownerName": "Google",