Skip to content

Instantly share code, notes, and snippets.

@erikeldridge
Last active Feb 12, 2018
Embed
What would you like to do?
Utils for working with GCloud service accounts

Setup

  1. Install and activate virtualenv (to avoid conflicts)
  2. Install google-oauth2l

Generate token

  1. Create a service account: https://console.cloud.google.com/iam-admin/serviceaccounts/project

  2. Download the private key, eg my-project-123asd.json

  3. Fetch token:

     $ oauth2l fetch --json ~/Downloads/my-project-123asd.json <scope>
    

Use token

    $ curl -H "authorization: bearer <token>" https://<service>.googleapis.com

Or

    $ curl https://<service>.googleapis.com?access_token=<token>

Inspect token

    $ curl https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=<token>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment