mirror of
https://github.com/GAM-team/GAM.git
synced 2025-07-10 14:43:34 +00:00
Handle G Suite Essentials unverified domain better
This commit is contained in:
@ -940,6 +940,9 @@ def buildGAPIObject(api):
|
|||||||
GC_Values[GC_CUSTOMER_ID] = MY_CUSTOMER
|
GC_Values[GC_CUSTOMER_ID] = MY_CUSTOMER
|
||||||
else:
|
else:
|
||||||
GC_Values[GC_DOMAIN] = _getValueFromOAuth('hd', credentials=credentials)
|
GC_Values[GC_DOMAIN] = _getValueFromOAuth('hd', credentials=credentials)
|
||||||
|
if GC_Values[GC_DOMAIN] == 'Unknown':
|
||||||
|
GC_Values[GC_DOMAIN] = getEmailAddressDomain(
|
||||||
|
_getValueFromOAuth('email'))
|
||||||
if not GC_Values[GC_CUSTOMER_ID]:
|
if not GC_Values[GC_CUSTOMER_ID]:
|
||||||
GC_Values[GC_CUSTOMER_ID] = MY_CUSTOMER
|
GC_Values[GC_CUSTOMER_ID] = MY_CUSTOMER
|
||||||
return service
|
return service
|
||||||
@ -1725,7 +1728,7 @@ def doPrintDomains():
|
|||||||
results = gapi.call(cd.domains(),
|
results = gapi.call(cd.domains(),
|
||||||
'list',
|
'list',
|
||||||
customer=GC_Values[GC_CUSTOMER_ID])
|
customer=GC_Values[GC_CUSTOMER_ID])
|
||||||
for domain in results['domains']:
|
for domain in results.get('domains', []):
|
||||||
domain_attributes = {}
|
domain_attributes = {}
|
||||||
domain['type'] = ['secondary', 'primary'][domain['isPrimary']]
|
domain['type'] = ['secondary', 'primary'][domain['isPrimary']]
|
||||||
for attr in domain:
|
for attr in domain:
|
||||||
@ -10443,15 +10446,21 @@ def doGetUserInfo(user_email=None):
|
|||||||
for alias in user['nonEditableAliases']:
|
for alias in user['nonEditableAliases']:
|
||||||
print(f' {alias}')
|
print(f' {alias}')
|
||||||
if getGroups:
|
if getGroups:
|
||||||
groups = gapi.get_all_pages(cd.groups(),
|
throw_reasons = [gapi_errors.ErrorReason.FORBIDDEN]
|
||||||
|
try:
|
||||||
|
groups = gapi.get_all_pages(
|
||||||
|
cd.groups(),
|
||||||
'list',
|
'list',
|
||||||
'groups',
|
'groups',
|
||||||
userKey=user_email,
|
userKey=user_email,
|
||||||
fields='groups(name,email),nextPageToken')
|
fields='groups(name,email),nextPageToken',
|
||||||
|
throw_reasons=throw_reasons)
|
||||||
if groups:
|
if groups:
|
||||||
print(f'Groups: ({len(groups)})')
|
print(f'Groups: ({len(groups)})')
|
||||||
for group in groups:
|
for group in groups:
|
||||||
print(f' {group["name"]} <{group["email"]}>')
|
print(f' {group["name"]} <{group["email"]}>')
|
||||||
|
except gapi.errors.GapiForbiddenError:
|
||||||
|
print('No access to show user groups.')
|
||||||
if getLicenses:
|
if getLicenses:
|
||||||
print('Licenses:')
|
print('Licenses:')
|
||||||
lic = buildGAPIObject('licensing')
|
lic = buildGAPIObject('licensing')
|
||||||
|
@ -14,11 +14,16 @@ def doGetCustomerInfo():
|
|||||||
customerKey=GC_Values[GC_CUSTOMER_ID])
|
customerKey=GC_Values[GC_CUSTOMER_ID])
|
||||||
print(f'Customer ID: {customer_info["id"]}')
|
print(f'Customer ID: {customer_info["id"]}')
|
||||||
print(f'Primary Domain: {customer_info["customerDomain"]}')
|
print(f'Primary Domain: {customer_info["customerDomain"]}')
|
||||||
result = gapi.call(cd.domains(),
|
try:
|
||||||
|
result = gapi.call(
|
||||||
|
cd.domains(),
|
||||||
'get',
|
'get',
|
||||||
customer=customer_info['id'],
|
customer=customer_info['id'],
|
||||||
domainName=customer_info['customerDomain'],
|
domainName=customer_info['customerDomain'],
|
||||||
fields='verified')
|
fields='verified',
|
||||||
|
throw_reasons=[gapi.errors.ErrorReason.DOMAIN_NOT_FOUND])
|
||||||
|
except gapi.errors.GapiDomainNotFoundError:
|
||||||
|
result = {'verified': False}
|
||||||
print(f'Primary Domain Verified: {result["verified"]}')
|
print(f'Primary Domain Verified: {result["verified"]}')
|
||||||
# If customer has changed primary domain customerCreationTime is date
|
# If customer has changed primary domain customerCreationTime is date
|
||||||
# of current primary being added, not customer create date.
|
# of current primary being added, not customer create date.
|
||||||
@ -66,7 +71,9 @@ def doGetCustomerInfo():
|
|||||||
customerId = None
|
customerId = None
|
||||||
rep = gapi_reports.buildGAPIObject()
|
rep = gapi_reports.buildGAPIObject()
|
||||||
usage = None
|
usage = None
|
||||||
throw_reasons = [gapi.errors.ErrorReason.INVALID]
|
throw_reasons = [
|
||||||
|
gapi.errors.ErrorReason.INVALID, gapi.errors.ErrorReason.FORBIDDEN
|
||||||
|
]
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
result = gapi.call(rep.customerUsageReports(),
|
result = gapi.call(rep.customerUsageReports(),
|
||||||
@ -78,6 +85,8 @@ def doGetCustomerInfo():
|
|||||||
except gapi.errors.GapiInvalidError as e:
|
except gapi.errors.GapiInvalidError as e:
|
||||||
tryDate = gapi_reports._adjust_date(str(e))
|
tryDate = gapi_reports._adjust_date(str(e))
|
||||||
continue
|
continue
|
||||||
|
except gapi.errors.GapiForbiddenError:
|
||||||
|
return
|
||||||
warnings = result.get('warnings', [])
|
warnings = result.get('warnings', [])
|
||||||
fullDataRequired = ['accounts']
|
fullDataRequired = ['accounts']
|
||||||
usage = result.get('usageReports')
|
usage = result.get('usageReports')
|
||||||
|
@ -130,7 +130,7 @@ SKUS = {
|
|||||||
'1010060001': {
|
'1010060001': {
|
||||||
'product': 'Google-Apps',
|
'product': 'Google-Apps',
|
||||||
'aliases': ['d4e', 'driveenterprise', 'drive4enterprise'],
|
'aliases': ['d4e', 'driveenterprise', 'drive4enterprise'],
|
||||||
'displayName': 'Drive Enterprise'
|
'displayName': 'G Suite Essentials'
|
||||||
},
|
},
|
||||||
'Google-Drive-storage-20GB': {
|
'Google-Drive-storage-20GB': {
|
||||||
'product': 'Google-Drive-storage',
|
'product': 'Google-Drive-storage',
|
||||||
|
Reference in New Issue
Block a user