mirror of
https://github.com/GAM-team/GAM.git
synced 2025-07-10 14:43:34 +00:00
Switch report uploads to use SA, remove Drive scope
This commit is contained in:
16
src/gam.py
16
src/gam.py
@ -8623,15 +8623,16 @@ def writeCSVfile(csvRows, titles, list_type, todrive):
|
|||||||
columns = len(csvRows[0])
|
columns = len(csvRows[0])
|
||||||
rows = len(csvRows)
|
rows = len(csvRows)
|
||||||
cell_count = rows * columns
|
cell_count = rows * columns
|
||||||
convert = True
|
mimeType = u'application/vnd.google-apps.spreadsheet'
|
||||||
if cell_count > 500000 or columns > 256:
|
if cell_count > 500000 or columns > 256:
|
||||||
print u'{0}{1}'.format(WARNING_PREFIX, MESSAGE_RESULTS_TOO_LARGE_FOR_GOOGLE_SPREADSHEET)
|
print u'{0}{1}'.format(WARNING_PREFIX, MESSAGE_RESULTS_TOO_LARGE_FOR_GOOGLE_SPREADSHEET)
|
||||||
convert = False
|
mimeType = u'text/csv'
|
||||||
drive = buildGAPIObject(u'drive')
|
admin_user = _getAdminUserFromOAuth()
|
||||||
result = callGAPI(drive.files(), u'insert', convert=convert,
|
admin_user, drive = buildDrive3GAPIObject(admin_user)
|
||||||
body={u'description': u' '.join(sys.argv), u'title': u'%s - %s' % (GC_Values[GC_DOMAIN], list_type), u'mimeType': u'text/csv'},
|
result = callGAPI(drive.files(), u'create', fields=u'webViewLink',
|
||||||
|
body={u'description': u' '.join(sys.argv), u'title': u'%s - %s' % (GC_Values[GC_DOMAIN], list_type), u'mimeType': mimeType},
|
||||||
media_body=googleapiclient.http.MediaInMemoryUpload(string_file.getvalue(), mimetype=u'text/csv'))
|
media_body=googleapiclient.http.MediaInMemoryUpload(string_file.getvalue(), mimetype=u'text/csv'))
|
||||||
file_url = result[u'alternateLink']
|
file_url = result[u'webViewLink']
|
||||||
if GC_Values[GC_NO_BROWSER]:
|
if GC_Values[GC_NO_BROWSER]:
|
||||||
msg_txt = u'Drive file uploaded to:\n %s' % file_url
|
msg_txt = u'Drive file uploaded to:\n %s' % file_url
|
||||||
msg_subj = u'%s - %s' % (GC_Values[GC_DOMAIN], list_type)
|
msg_subj = u'%s - %s' % (GC_Values[GC_DOMAIN], list_type)
|
||||||
@ -9893,9 +9894,6 @@ OAUTH2_SCOPES = [
|
|||||||
{u'name': u'Usage Reports API',
|
{u'name': u'Usage Reports API',
|
||||||
u'subscopes': [],
|
u'subscopes': [],
|
||||||
u'scopes': u'https://www.googleapis.com/auth/admin.reports.usage.readonly'},
|
u'scopes': u'https://www.googleapis.com/auth/admin.reports.usage.readonly'},
|
||||||
{u'name': u'Drive API - create report docs only',
|
|
||||||
u'subscopes': [],
|
|
||||||
u'scopes': u'https://www.googleapis.com/auth/drive.file'},
|
|
||||||
{u'name': u'License Manager API',
|
{u'name': u'License Manager API',
|
||||||
u'subscopes': [],
|
u'subscopes': [],
|
||||||
u'scopes': u'https://www.googleapis.com/auth/apps.licensing'},
|
u'scopes': u'https://www.googleapis.com/auth/apps.licensing'},
|
||||||
|
Reference in New Issue
Block a user