Removing client_secrets.json as outdated and onerous. Untested.
authorBryan <btbonval@gmail.com>
Mon, 15 Jun 2015 03:10:29 +0000 (23:10 -0400)
committerBryan <btbonval@gmail.com>
Mon, 15 Jun 2015 03:10:29 +0000 (23:10 -0400)
closes 436

.env.example
README.md
karmaworld/apps/notes/gdrive.py

index f9d78419220daf3f459c6170bd42afaef7d2c801..3603ed8e6c5dde3f2b02fedca361edce4c80c305 100644 (file)
@@ -9,7 +9,7 @@ CLOUDFRONT_DOMAIN='foo.cloudfront.net'
 
 SSL_REDIRECT=true
 
-GOOGLE_CLIENT_SECRETS='{"web": {"json": "goes here"} }'
+GOOGLE_SERVICE_EMAIL='numbers-alphanumerics@developer.gserviceaccount.com'
 GOOGLE_USER='GoogleApps@Email.Address'
 GOOGLE_SERVICE_KEY_BASE64='Base64EncodedP12FileContentsGoHere'
 
index 187d69ac52299423150fedd03b6dd2ca89ff19b9..4be9b4358c807e3dbc830464ac979ce731818721 100644 (file)
--- a/README.md
+++ b/README.md
@@ -274,11 +274,20 @@ Follow [Google's instructions](https://developers.google.com/drive/web/auth/web-
 to create a Google Drive service account. If using Google Apps, it is worth
 looking at [these instructions](https://developers.google.com/drive/delegation).
 
+Populate the `GOOGLE_USER` environment variable with the email address of the
+user whose Google Drive will be accessed. This is typically your own email
+address.
+
 Google Drive used to use p12 files by default. Now a new-style JSON file is
 downloaded by default when creating new credentials. Until the code has been
 [updated](https://github.com/FinalsClub/karmaworld/issues/437) to use the
 new-style JSON file, make sure to click the `Generate a new P12 key` button.
 
+While on the Credentials page (with the `Generate a new P12 key` button
+visible), note the Service account Email address. It will have a format like
+`numbers-alphanumerics@developer.gserviceaccount.com`. Copy this value and
+paste it into the `GOOGLE_SERVICE_EMAIL` environment variable.
+
 Convert the p12 file into a Base64 encoded string for the
 `GOOGLE_SERVICE_KEY_BASE64` environment variable. There are many ways to do
 this. If Python is available, the
index 7b958424309e42bc00aab221e67ac8433fa1dc91..12d0f2dc91c323b188f217fcfbdc2627a8b888da 100644 (file)
@@ -33,7 +33,7 @@ logger = logging.getLogger(__name__)
 PDF_MIMETYPE = 'application/pdf'
 PPT_MIMETYPES = ['application/vnd.ms-powerpoint', 'application/vnd.openxmlformats-officedocument.presentationml.presentation']
 
-GOOGLE_CLIENT_SECRETS = os.environ['GOOGLE_CLIENT_SECRETS']
+GOOGLE_SERVICE_EMAIL = os.environ['GOOGLE_SERVICE_EMAIL']
 GOOGLE_SERVICE_KEY_BASE64 = os.environ['GOOGLE_SERVICE_KEY_BASE64']
 GOOGLE_USER = os.environ['GOOGLE_USER']
 
@@ -49,12 +49,9 @@ def build_api_service():
     https://developers.google.com/drive/delegation
     """
 
-    # Extract the service address from the client secret
-    service_user = json.loads(GOOGLE_CLIENT_SECRETS)['web']['client_email']
-
     # Pull in the service's p12 private key.
     p12 = base64.decodestring(GOOGLE_SERVICE_KEY_BASE64)
-    credentials = SignedJwtAssertionCredentials(service_user, p12,
+    credentials = SignedJwtAssertionCredentials(GOOGLE_SERVICE_EMAIL, p12,
                                scope='https://www.googleapis.com/auth/drive',
                                sub=GOOGLE_USER)