mirror of
https://github.com/GAM-team/GAM.git
synced 2026-07-03 12:21:35 +00:00
return nice error if oauth2service.json missing
This commit is contained in:
10
gam.py
10
gam.py
@@ -572,6 +572,11 @@ def buildGAPIServiceObject(api, act_as=None, soft_errors=False):
|
|||||||
oauth2servicefilep12 = u'%s.p12' % oauth2servicefile
|
oauth2servicefilep12 = u'%s.p12' % oauth2servicefile
|
||||||
try:
|
try:
|
||||||
json_string = open(oauth2servicefilejson).read()
|
json_string = open(oauth2servicefilejson).read()
|
||||||
|
except IOError, e:
|
||||||
|
print u'Error: %s' % e
|
||||||
|
print u''
|
||||||
|
print u'Please follow the instructions at:\n\nhttps://github.com/jay0lee/GAM/wiki/CreatingClientSecretsFile#creating-your-own-oauth2servicejson\n\nto setup a Service Account'
|
||||||
|
sys.exit(6)
|
||||||
json_data = json.loads(json_string)
|
json_data = json.loads(json_string)
|
||||||
try:
|
try:
|
||||||
SERVICE_ACCOUNT_EMAIL = json_data[u'web'][u'client_email']
|
SERVICE_ACCOUNT_EMAIL = json_data[u'web'][u'client_email']
|
||||||
@@ -579,11 +584,6 @@ def buildGAPIServiceObject(api, act_as=None, soft_errors=False):
|
|||||||
f = file(oauth2servicefilep12, 'rb')
|
f = file(oauth2servicefilep12, 'rb')
|
||||||
key = f.read()
|
key = f.read()
|
||||||
f.close()
|
f.close()
|
||||||
except IOError, e:
|
|
||||||
print u'Error: %s' % e
|
|
||||||
print u''
|
|
||||||
print u'Please follow the instructions at:\n\nhttps://github.com/jay0lee/GAM/wiki/CreatingClientSecretsFile#creating-your-own-oauth2servicejson\n\nto setup a Service Account'
|
|
||||||
sys.exit(6)
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
# new format with config and data in the .json file...
|
# new format with config and data in the .json file...
|
||||||
SERVICE_ACCOUNT_EMAIL = json_data[u'client_email']
|
SERVICE_ACCOUNT_EMAIL = json_data[u'client_email']
|
||||||
|
|||||||
Reference in New Issue
Block a user