Connecting to GCP using OAuth and the Web API data source

If you’re trying to connect with GCP (Google Cloud Platform) with the Web API data source, here are the settings that worked for me.

In this example, I was integrating with GCP Error Reporting.

1 Start by creating an OAuth 2.0 client ID in the GCP console:

  • Application type: select Web application
  • Authorised redirect URIs: add https://app.squaredup.com/settings/pluginsoauth2

Once created, you will need to use the Client ID and Client secret below.

If you’re reusing existing credentials, see Adam’s note below.

2 Configure the Web API data source

  • Base URL: from the GCP API docs e.g. https://clouderrorreporting.googleapis.com/v1beta1/projects/<my-project-id>/
  • Authentication: OAuth 2
  • Token URL: https://oauth2.googleapis.com/token
  • Client ID: <Client ID from step 1>
  • Client Secret: <Client secret from above>
    Authorization Scope: You can find this on the docs page for the HTTP endpoint e.g. for Method: projects.groupStats.list  |  Error Reporting  |  Google Cloud it is https://www.googleapis.com/auth/cloud-platform
  • How to send credentials to the Token URL: Query string
  • Grant Type: Authorization Code
  • Authorization URL: https://accounts.google.com/o/oauth2/auth?access_type=offline&include_granted_scopes=true&response_type=code

It’s a good idea to save your data source settings before clicking Sign In, just in case something goes wrong and you lose the settings.

  • Click ‘Sign in’
  • If all goes well, you should be authenticated!
  • Now you’re ready to make a test request. My test was:
  • Endpoint path to test: groupStats
  • HTTP method for the test: GET
  • Send!

Hope this helps!

3 Likes

Nice write up.

One thing to add that’s stumped me a few times. Google only provide a refresh token the first time you use a particular client ID / secret combo, so if you’re using creds you’ve used before, include &prompt=consent on the end of the authorization URL and it’ll ensure that a refresh token is provided.

Without it, you might get an error during the OAuth sign-in process.

Once you’ve got it connected and happy, drop that off the URL again and save your config

2 Likes