- Install and activate virtualenv (to avoid conflicts)
- Install google-oauth2l
-
Create a service account: https://console.cloud.google.com/iam-admin/serviceaccounts/project
-
Download the private key, eg my-project-123asd.json
-
Fetch token:
$ oauth2l fetch --json ~/Downloads/my-project-123asd.json <scope>
$ curl -H "authorization: bearer <token>" https://<service>.googleapis.com
Or
$ curl https://<service>.googleapis.com?access_token=<token>
$ curl https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=<token>