Follow this guide to get the GSheets-Plaid web server running on your local machine.
Prerequisites:
- A Google account
- A Plaid account
- Python 3.10 or higher
gsheets-plaid
installedpython3 -m pip install gsheets-plaid
- Go to the Manage resources page in the Google Cloud console.
- On the Select organization drop-down list at the top of the page, select the organization resource in which you want to create a project. If you are a free trial user, skip this step, as this list does not appear.
- Click Create Project.
- In the New Project window that appears, enter a project name and select a billing account as applicable. A project name can contain only letters, numbers, single quotes, hyphens, spaces, or exclamation points, and must be between 4 and 30 characters.
- Enter the parent organization or folder resource in the Location box. That resource will be the hierarchical parent of the new project. If No organization is an option, you can select it to create your new project as the top level of its own resource hierarchy.
- When you're finished entering new project details, click Create.
Enable the following APIs:
- Google Sheets API
- Cloud Run API
- In the Google Cloud console, go to the APIs & services Library for your project.
- At the top-left, click Menu > APIs & Services > Library
- Search for the API in the search bar.
- Select the corresponding result.
- Click Enable.
- Repeat these steps until all required APIs are enabled.
- In the Google Cloud console, go to the APIs & services OAuth consent screen page for your project.
- At the top-left, click Menu > APIs & Services > OAuth consent screen
- Select External
- Fill out the required fields in the form.
- App name: choose a name you like.
- User support email: you can put your own email address.
- Developer contact information: you can put your own email address again.
- Click Save and Continue.
- Click Add or Remove Scopes.
- Add the following scopes (tip: use the filter search bar to narrow the results):
https://www.googleapis.com/auth/drive.file
- Click Save and Continue.
- Click Add Users.
- Add yourself as a test user (enter an @gmail.com address that you own).
- Click Add.
- Click Save and Continue.
- Review the information, then click Back to Dashboard.
In order to spin up the local web server, we need to pass in several environment variables. To make things easier, we'll record the data in a script for easy reference.
- Create a new file named
run_web_server.sh
. - Add executable permissions to the script.
chmod +x run_web_server.sh
- Using your favorite text editor, paste in the following template as the contents of
run_web_server.sh
:
# Command for spinning up gsheets_plaid local web server
GOOGLE_CLOUD_CLIENT_ID= \
GOOGLE_CLOUD_CLIENT_CONFIG= \
GOOGLE_APPLICATION_CREDENTIALS= \
FLASK_SECRET_KEY= \
python3 -m gsheets_plaid
- In the Google Cloud console, go to the APIs & services Credentials page for your project.
- At the top-left, click Menu > APIs & Services > Credentials
- Click Create Credentials > OAuth client ID.
- For Application type, select Web application.
- Under Authorized JavaScript Origins, add the following URIs:
https://localhost
https://localhost:8080
- Under Authorized Redirect URIs, add the following URI:
https://localhost/google-oauth-callback
- Click Create.
- In the popup that appears, copy the value in Your Client ID and paste it in your script as the value for
GOOGLE_CLOUD_CLIENT_ID
.- Note: If the popup didn't appear for some reason, or if you have previously created an OAuth Client ID, click the download icon on the corresponding ID
- Click Download JSON
- Click OK.
- Enter the filepath for this JSON file you just downloaded in your script as the value for
GOOGLE_CLOUD_CLIENT_CONFIG
.
At this point, your script should look something like this:
# Command for spinning up gsheets_plaid local web server
GOOGLE_CLOUD_CLIENT_ID=123456789-abcdefghijk123456789.apps.googleusercontent.com \
GOOGLE_CLOUD_CLIENT_CONFIG=/Users/<you>/Downloads/client_secret_123456789-abcdefghijk123456789.apps.googleusercontent.com.json \
GOOGLE_APPLICATION_CREDENTIALS= \
FLASK_SECRET_KEY= \
python3 -m gsheets_plaid
- In the Google Cloud console, go to the APIs & services Credentials page for your project.
- At the top-left, click Menu > APIs & Services > Credentials
- In the Service Accounts section, select the edit icon for the Default Compute Service Account.
- Click Keys.
- Select Add Key > Add new key.
- Select JSON as the key type, then click Create.
- The file should download automatically.
- Enter the filepath for this JSON file in your script as the value for
GOOGLE_APPLICATION_CREDENTIALS
.
Now your script should look like this:
# Command for spinning up gsheets_plaid local web server
GOOGLE_CLOUD_CLIENT_ID=123456789-abcdefghijk123456789.apps.googleusercontent.com \
GOOGLE_CLOUD_CLIENT_CONFIG=/Users/<you>/Downloads/client_secret_123456789-abcdefghijk123456789.apps.googleusercontent.com.json \
GOOGLE_APPLICATION_CREDENTIALS=/Users/<you>/Downloads/project-name-123456-abcdefg12345678.json \
FLASK_SECRET_KEY= \
python3 -m gsheets_plaid
The GSheets-Plaid web server uses the Flask micro web framework. In order to store a cookie, Flask requires you to provide a secret key that is used to cryptographically sign the cookie, so that bad actors can't edit the data in the cookie.
An easy way to get a random string that we can use as a secret key is to run this command:
python -c 'import secrets; print(secrets.token_hex())'
The output will be a random string of letters and numbers, like this:
f15e697ad4c9480c385867699152a52ba8a70ee0f70382999989d7924ae23f76
Generate a secret key and save it in your script as the value for FLASK_SECRET_KEY
.
Your script should now look like this:
# Command for spinning up gsheets_plaid local web server
GOOGLE_CLOUD_CLIENT_ID=123456789-abcdefghijk123456789.apps.googleusercontent.com \
GOOGLE_CLOUD_CLIENT_CONFIG=/Users/<you>/Downloads/client_secret_123456789-abcdefghijk123456789.apps.googleusercontent.com.json \
GOOGLE_APPLICATION_CREDENTIALS=/Users/<you>/Downloads/project-name-123456-abcdefg12345678.json \
FLASK_SECRET_KEY=f15e697ad4c9480c385867699152a52ba8a70ee0f70382999989d7924ae23f76 \
python3 -m gsheets_plaid
If you haven't signed up already, create a Plaid developer account.
Add the redirect URI https://localhost:8080/google-oauth-callback
to the list of allowed redirect URIs in the Plaid Dashboard (Team Settings > API > Allowed redirect URIs > Configure).
Now we can run the web server script.
./run_web_server.sh
Once you sign in with your email that you whitelisted as a test user, you should see a checklist of items to complete before syncing your transactions.
Some things to note:
- When adding bank accounts, if you are using the
sandbox
environment, note that the bank account credentials are provided at the bottom of the screen. If you are using thedevelopment
environment, use your actual bank account credentials. - In the
development
environment, you are only given 5 tokens to use. If you submit a ticket on the Plaid Dashboard you can get it bumped up to 100 tokens, which should be more than plenty for personal usage. - Once you have added all the bank accounts you want you can close the browser tab and enter
CTRL+C
in the terminal to kill the web server process.
That's it! 🎉 Hopefully you're inspired to write some cool formulas and make neat charts using this raw transaction data.