-
Notifications
You must be signed in to change notification settings - Fork 407
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2455 from StateVoicesNational/re/google-api-stuff
#2455 Google API, Base64 implementation + other goodies
- Loading branch information
Showing
10 changed files
with
171 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,3 +25,4 @@ CONFIG_FILE.json | |
scratch/ | ||
cypress/screenshots | ||
cypress/videos | ||
spoke-pm2.config.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,9 +48,38 @@ This doc and associated feature is under construction/maintenance. Please consid | |
{ "type": "service_account", "project_id": "quickstart-1552345943126", "private_key_id": "1f029699545c3a00039b7ed0894f60d8bccfb970", "private_key": "-----BEGIN PRIVATE KEY-----\naVeryLongPrivateKey\n-----END PRIVATE KEY-----\n", "client_email": "[email protected]", "client_id": "103778937997709997381", "auth_uri": "https://accounts.google.com/o/oauth2/auth", "token_uri": "https://oauth2.googleapis.com/token", "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/test-252%40quickstart-1552345943126.iam.gserviceaccount.com" } | ||
``` | ||
|
||
17. In the Spoke `.env` file, or the environment variables section in Heroku settings, or in whatever your platform uses for configuration, create a key called `GOOGLE_SECRET` and set its value to the single line of text you created in step 16. (If you're using a `.env` file you must surround it by single quotes. If you're using Heroku you don't need to add quotes.) For AWS Lambda, there are [special deployment instructions](HOWTO_DEPLOYING_AWS_LAMBDA.md#environment-variable-maximum-4k) | ||
18. Restart Spoke after changing the configuration. | ||
19. Grab the value of the `client_email` key in the `JSON` in step 16, without the quotes (in our example, it's `[email protected]`). This is the email address with which you must share documents you want to import. | ||
17. In version 14.1, GOOGLE_SECRET was converted to BASE64_GOOGLE_SECRET for easier handling. We recommend you convert your Google Secret JSON to Base64 using this simple script: | ||
``` | ||
// Import your Google Secret JSON here | ||
const json = require('pathToGoogleSecret.json'); | ||
const jsonString = JSON.stringify(json); | ||
let decode; | ||
// convert to base64 | ||
const buffer_UTF = new Buffer.from(jsonString, 'utf-8'); | ||
const output_BASE64 = buff_UTF.toString('base64'); | ||
// convert back to string for QA | ||
const buffer_BASE64 = new Buffer.from(output_BASE64, 'base64'); | ||
const output_UTF = buffer_BASE64.toString('utf-8'); | ||
try { | ||
decode = JSON.parse(output2); | ||
} catch (err) { | ||
console.error("Failed", err) | ||
} | ||
if (!!decode) { | ||
console.log(output) | ||
} | ||
``` | ||
|
||
Run this using Node. | ||
|
||
18. In the Spoke `.env` file, or the environment variables section in Heroku settings, or in whatever your platform uses for configuration, create a key called `BASE64_GOOGLE_SECRET` and set its value to the single line of text you created in step 16. (If you're using a `.env` file you must surround it by single quotes. If you're using Heroku you don't need to add quotes.) For AWS Lambda, there are [special deployment instructions](HOWTO_DEPLOYING_AWS_LAMBDA.md#environment-variable-maximum-4k) | ||
19. Restart Spoke after changing the configuration. | ||
|
||
## Create script documents | ||
|
||
|
@@ -59,7 +88,7 @@ This doc and associated feature is under construction/maintenance. Please consid | |
3. Share the script document with your API user. | ||
- Go to the document in Google Docs. | ||
- Click `Share` in the upper right corner of the browser window. The `Share with others` dialog will appear. | ||
- Paste the email address from step 19 above (in this example, `[email protected]`) in the `People` field in the lower section of the `Share with others` dialog. | ||
- Paste the email address found in the text of the Import Scripts dropdown found in the Campaign Edit page. This email address should look something like this:`[email protected]` | ||
- Clear the `Notify people` checkbox. | ||
- Click `OK`. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.