Command-line utility to manage Google APIs authorization (OAuth2) tokens.
Useful to generate access/refresh tokens (for Installed Applications).
I haven’t published any binary so far because it has been used for personal purposes only.
Now, I could push a zip file onto some cloud file storage service if kindly asked ;).
In the meantime, to run this tools, you need to build it and generate an executable script.
He are the main steps:
-
clone this repo
-
make sure you have Java 7+, Scala 2.11 and SBT (the last two can be installed very easily on OS X with Homebrew)
-
simply run
sbt stage
and a directory with all the needed files will be generated under./target/universal/stage
(thanks SBT Native Packager !) -
then run the shell script under the
bin/
directory
org.ozb.google.oauth2 0.1 : Google OAuth2 command-line utils Usage: org.ozb.google.oauth2 [GetTokenResponse|RefreshAccessToken] [options] --help prints this usage text --clientId <value> clientId --clientSecret <value> clientSecret --clientSecretJson <value> clientSecret JSON file path --redirectUri <value> redirectUri (by default 'urn:ietf:wg:oauth:2.0:oob') Command: GetTokenResponse [options] Get OAuth2 authorization token (access token and refresh token) --scopes <value> scopes (e.g."https://spreadsheets.google.com/feeds") Command: RefreshAccessToken [options] Refresh access token --refreshToken <value>
Upon successful invocation, the token response will be printed out at the console.
The refresh token should be stored in long-term storage to request a new access token when it’s no longer valid.
You can specify the clientId and the clientSecret in three ways:
-
either by passing them in the command line
--clientId xxxx --clientSecret yyyy ...
-
or by specifying the clientSecrets.json file (downloaded from the Google Developers Console)
--clientSecretJson path/to/client_secret.json ...
-
or finally, by entering them directly in the terminal if no clientId/clientSecret/clientSecretJson option is passed in the command-line
ozb-google-oauth2-utils GetTokenResponse --clientSecretJson /path/to/yours/client_secret.json --scopes https://spreadsheets.google.com/feeds
ozb-google-oauth2-utils RefreshAccessToken --clientSecretJson /path/to/yours/client_secret.json
In this case, the refresh token will be asked at the console (but you can pass it on the command-line)