Do not truncate client_id by default

This commit is contained in:
Ross Scroggs
2024-04-22 17:17:47 -07:00
parent 10a6348ddd
commit b384bdb503
2 changed files with 8 additions and 3 deletions

View File

@@ -4446,6 +4446,9 @@ def getOauth2TxtCredentials(exitOnError=True, api=None, noDASA=False, refreshOnl
else:
GM.Globals[GM.CREDENTIALS_SCOPES] = set(jsonDict.pop('scopes', API.REQUIRED_SCOPES))
token_expiry = jsonDict.get('token_expiry', REFRESH_EXPIRY)
if GC.Values[GC.TRUNCATE_CLIENT_ID]:
# chop off .apps.googleusercontent.com suffix as it's not needed and we need to keep things short for the Auth URL.
jsonDict['client_id'] = re.sub(r'\.apps\.googleusercontent\.com$', '', jsonDict['client_id'])
creds = google.oauth2.credentials.Credentials.from_authorized_user_info(jsonDict)
if 'id_token_jwt' not in jsonDict:
creds.token = jsonDict['token']
@@ -10393,9 +10396,7 @@ def getOAuthClientIDAndSecret():
cs_json = json.loads(cs_data)
if not cs_json:
systemErrorExit(CLIENT_SECRETS_JSON_REQUIRED_RC, Msg.NO_CLIENT_ACCESS_CREATE_UPDATE_ALLOWED)
# chop off .apps.googleusercontent.com suffix as it's not needed and we need to keep things short for the Auth URL.
return (re.sub(r'\.apps\.googleusercontent\.com$', '', cs_json['installed']['client_id']),
cs_json['installed']['client_secret'])
return (cs_json['installed']['client_id'], cs_json['installed']['client_secret'])
except (IndexError, KeyError, SyntaxError, TypeError, ValueError) as e:
invalidClientSecretsJsonExit(str(e))

View File

@@ -288,6 +288,8 @@ TODRIVE_TIMEZONE = 'todrive_timezone'
TODRIVE_UPLOAD_NODATA = 'todrive_upload_nodata'
# User for todrive files
TODRIVE_USER = 'todrive_user'
# Truncate Client ID
TRUNCATE_CLIENT_ID = 'truncate_client_id'
# Update CrOS org unit with orgUnitId
UPDATE_CROS_OU_WITH_ID = 'update_cros_ou_with_id'
# Use course owner for course access
@@ -430,6 +432,7 @@ Defaults = {
TODRIVE_TIMEZONE: '',
TODRIVE_UPLOAD_NODATA: TRUE,
TODRIVE_USER: '',
TRUNCATE_CLIENT_ID: FALSE,
UPDATE_CROS_OU_WITH_ID: FALSE,
USE_COURSE_OWNER_ACCESS: FALSE,
USE_PROJECTID_AS_NAME: FALSE,
@@ -590,6 +593,7 @@ VAR_INFO = {
TODRIVE_TIMEZONE: {VAR_TYPE: TYPE_STRING, VAR_LIMITS: (0, None)},
TODRIVE_UPLOAD_NODATA: {VAR_TYPE: TYPE_BOOLEAN},
TODRIVE_USER: {VAR_TYPE: TYPE_STRING, VAR_LIMITS: (0, None)},
TRUNCATE_CLIENT_ID: {VAR_TYPE: TYPE_BOOLEAN},
UPDATE_CROS_OU_WITH_ID: {VAR_TYPE: TYPE_BOOLEAN},
USE_COURSE_OWNER_ACCESS: {VAR_TYPE: TYPE_BOOLEAN},
USE_PROJECTID_AS_NAME: {VAR_TYPE: TYPE_BOOLEAN},