mirror of
https://github.com/GAM-team/GAM.git
synced 2026-07-03 12:21:35 +00:00
Updated gam <UserTypeEntity> print|show webmastersites to handle permissionDenied
This commit is contained in:
@@ -1,3 +1,11 @@
|
|||||||
|
7.17.02
|
||||||
|
|
||||||
|
Updated `gam <UserTypeEntity> print|show webmastersites` to handle the following error
|
||||||
|
that occurs if you haven't updated your project to include the Google Search Console API.
|
||||||
|
```
|
||||||
|
ERROR: 403: permissionDenied - Google Search Console API has not been used in project 111055363999 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/searchconsole.googleapis.com/overview?project=111055363999 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.
|
||||||
|
```
|
||||||
|
|
||||||
7.17.01
|
7.17.01
|
||||||
|
|
||||||
Fixed bug in `gam <UserTypeEntity> show webmastersites` that caused a trap.
|
Fixed bug in `gam <UserTypeEntity> show webmastersites` that caused a trap.
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ https://github.com/GAM-team/GAM/wiki
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
__author__ = 'GAM Team <google-apps-manager@googlegroups.com>'
|
__author__ = 'GAM Team <google-apps-manager@googlegroups.com>'
|
||||||
__version__ = '7.17.01'
|
__version__ = '7.17.02'
|
||||||
__license__ = 'Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)'
|
__license__ = 'Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)'
|
||||||
|
|
||||||
#pylint: disable=wrong-import-position
|
#pylint: disable=wrong-import-position
|
||||||
@@ -5688,19 +5688,22 @@ def getUserEmailFromID(uid, cd):
|
|||||||
try:
|
try:
|
||||||
result = callGAPI(cd.users(), 'get',
|
result = callGAPI(cd.users(), 'get',
|
||||||
throwReasons=GAPI.USER_GET_THROW_REASONS,
|
throwReasons=GAPI.USER_GET_THROW_REASONS,
|
||||||
|
retryReasons=GAPI.SERVICE_NOT_AVAILABLE_RETRY_REASONS,
|
||||||
userKey=uid, fields='primaryEmail')
|
userKey=uid, fields='primaryEmail')
|
||||||
return result.get('primaryEmail')
|
return result.get('primaryEmail')
|
||||||
except (GAPI.userNotFound, GAPI.domainNotFound, GAPI.domainCannotUseApis, GAPI.forbidden,
|
except (GAPI.userNotFound, GAPI.domainNotFound, GAPI.domainCannotUseApis, GAPI.forbidden,
|
||||||
GAPI.badRequest, GAPI.backendError, GAPI.systemError):
|
GAPI.badRequest, GAPI.backendError, GAPI.systemError, GAPI.serviceNotAvailable):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def getGroupEmailFromID(uid, cd):
|
def getGroupEmailFromID(uid, cd):
|
||||||
try:
|
try:
|
||||||
result = callGAPI(cd.groups(), 'get',
|
result = callGAPI(cd.groups(), 'get',
|
||||||
throwReasons=GAPI.GROUP_GET_THROW_REASONS,
|
throwReasons=GAPI.GROUP_GET_THROW_REASONS,
|
||||||
|
retryReasons=GAPI.SERVICE_NOT_AVAILABLE_RETRY_REASONS,
|
||||||
groupKey=uid, fields='email')
|
groupKey=uid, fields='email')
|
||||||
return result.get('email')
|
return result.get('email')
|
||||||
except (GAPI.groupNotFound, GAPI.domainNotFound, GAPI.domainCannotUseApis, GAPI.forbidden, GAPI.badRequest):
|
except (GAPI.groupNotFound, GAPI.domainNotFound, GAPI.domainCannotUseApis, GAPI.forbidden,
|
||||||
|
GAPI.badRequest, GAPI.serviceNotAvailable):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def getServiceAccountEmailFromID(account_id, sal=None):
|
def getServiceAccountEmailFromID(account_id, sal=None):
|
||||||
@@ -47129,7 +47132,11 @@ def printShowWebMasterSites(users):
|
|||||||
user, searchconsole = buildGAPIServiceObject(API.SEARCHCONSOLE, user, i, count)
|
user, searchconsole = buildGAPIServiceObject(API.SEARCHCONSOLE, user, i, count)
|
||||||
if not searchconsole:
|
if not searchconsole:
|
||||||
continue
|
continue
|
||||||
sites = callGAPIitems(searchconsole.sites(), 'list', 'siteEntry')
|
try:
|
||||||
|
sites = callGAPIitems(searchconsole.sites(), 'list', 'siteEntry',
|
||||||
|
throwReasons=[GAPI.PERMISSION_DENIED])
|
||||||
|
except GAPI.permissionDenied as e:
|
||||||
|
accessErrorExitNonDirectory(API.SEARCHCONSOLE, str(e))
|
||||||
jcount = len(sites)
|
jcount = len(sites)
|
||||||
if not csvPF:
|
if not csvPF:
|
||||||
entityPerformActionNumItems([Ent.USER, user], jcount, Ent.WEB_MASTERSITE, i, count)
|
entityPerformActionNumItems([Ent.USER, user], jcount, Ent.WEB_MASTERSITE, i, count)
|
||||||
|
|||||||
Reference in New Issue
Block a user