Skip to main content

command-line google oauth tools

Project description

oauth2l
-------

[![Build Status](https://travis-ci.org/google/oauth2l.svg?branch=master)](https://travis-ci.org/google/oauth2l)

`oauth2l` (pronounced "oauth tool") is a simple command-line tool that can be
used to interact with Google OAuth authentication system. Its primary use is
to fetch and print OAuth 2.0 access tokens, which can be used with other
command-line tools and shell scripts.

## Overview

`oauth2l` supports multiple OAuth 2.0 authentication flows for both user
accounts and service accounts:

* When running inside Google Compute Engine (GCE), it uses the credentials of
the current GCE service account (if it exists).

* When running under user context that has an active Google Cloud SDK (gcloud)
session, it uses the credentials of the gcloud session.

* When running with command line flag `--json xxx`, where `xxx` points to a
JSON credential file -- either a service account or an oauth client id --
downloaded from Google API Console, `oauth2l` will use the JSON file to start
the OAuth session.

* Otherwise, `oauth2l` will use its own oauth client identity to start OAuth
session.

## Install

pip install google-oauth2l

## Commands

### fetch

Fetch and print an access token for the specified oauth scopes. For example,
the following command prints access token for the following OAuth2 scopes:

* https://www.googleapis.com/auth/userinfo.email
* https://www.googleapis.com/auth/cloud-platform

```
$ oauth2l fetch userinfo.email cloud-platform
ya29.zyxwvutsrqpnmolkjihgfedcba
```

### header

Same as `fetch`, except that we print the token in HTTP header format:

```
$ oauth2l header userinfo.email
Authorization: Bearer ya29.zyxwvutsrqpnmolkjihgfedcba
```

The `header` command is designed to be easy to use with `curl`. For example,
the following command uses the BigQuery API to list all projects.

```
$ curl -H "$(oauth2l header bigquery)" 'https://www.googleapis.com/bigquery/v2/projects'
```

### info

Print information about a valid token. This always includes the list of scopes
and expiration time. If the token has either the
`https://www.googleapis.com/auth/userinfo.email` or
`https://www.googleapis.com/auth/plus.me` scope, this also includes the email
address of the user for whom this token was created.

```
$ oauth2l info $(oauth2l fetch bigquery)
{
"expires_in": 3599,
"scope": "https://www.googleapis.com/auth/bigquery",
"email": "user@gmail.com"
}
```

(The actual output will likely have a few more fields.)

### test

Test a token. This sets an exit code of 0 for a valid token and 1 otherwise,
which can be useful in shell pipelines.

```
$ oauth2l test ya29.zyxwvutsrqpnmolkjihgfedcba
$ echo $?
0
$ oauth2l test ya29.justkiddingmadethisoneup
$ echo $?
1
```

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

google-oauth2l-0.8.0.zip (18.0 kB view details)

Uploaded Source

google-oauth2l-0.8.0.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

google_oauth2l-0.8.0-py2-none-any.whl (11.3 kB view details)

Uploaded Python 2

File details

Details for the file google-oauth2l-0.8.0.zip.

File metadata

  • Download URL: google-oauth2l-0.8.0.zip
  • Upload date:
  • Size: 18.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for google-oauth2l-0.8.0.zip
Algorithm Hash digest
SHA256 3d1377b984639a07b52cf1882d8eadd7b0bc888e82d9a4a9adcdcb4340d7c979
MD5 a4b7b77b137a0b9ce33db590e114a0e8
BLAKE2b-256 b616a5b678d92d9ca4a8d32784af57d5a769a28392046a81cb17b3d1e6e1f610

See more details on using hashes here.

File details

Details for the file google-oauth2l-0.8.0.tar.gz.

File metadata

File hashes

Hashes for google-oauth2l-0.8.0.tar.gz
Algorithm Hash digest
SHA256 7c6e8798c98e60908190b6d1a1a9f102cf044bf6e70b1d2e6dc425254c90a50d
MD5 7c48fd632852bbe4e0069b6211c7730a
BLAKE2b-256 f20f8d3449a18dbe29c0c4f60f708e229f3b227704d3fa8b012e656952059153

See more details on using hashes here.

File details

Details for the file google_oauth2l-0.8.0-py2-none-any.whl.

File metadata

File hashes

Hashes for google_oauth2l-0.8.0-py2-none-any.whl
Algorithm Hash digest
SHA256 4d7166e7e2fcc9ad79f3a79a211a80354232432b9b6eb4149d751ebffc09982e
MD5 90b6dfab9993f31a33d3e905fb6f093d
BLAKE2b-256 84231154d83f3524ae425084f8503692619d368b81d348d76396363747efabee

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page