GitXplorerGitXplorer
A

gcloud_cl_user_auth.dart

public
0 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
ce90e09c902f77573107b87ba745769ead3a5d2b

Improved README

AArgentiApparatus committed 8 years ago
Unverified
293a371c2c7e871eb6f578af41ad250a44f32000

Utilities and library for Google cloud command line user credentials

tt6iz8t48 committed 9 years ago

README

The README file for this repository.

Google Cloud Command Line User Authentication

User authentication utility:

  • Authenticate a Google cloud command line app with a Google account
  • Write credentials to a json file
  • Refresh credentials

User authentication library:

  • Use the credentials json file in a command line program
  • Automatically refresh crredentials while command line program running

Github Page

Using the Utility:

Activate the Utility:

pub global activate path/to/gcloud_user_auth -s path

Set up Google OAuth Command Line Client

Go to Google API Manager credentials page https://console.developers.google.com/apis/credentials to create Google API client credentials.

  • Credentials type: OAuth Client ID
  • Application type: Other

API client will be assigned a client identifier and a client secret.

Authenticating the client

Create a client json file containing the client identifier and secret

{
  "clientId": {
    "identifier": "...apps.googleusercontent.com",
    "secret":     "..."
  }
}

Run the authentiction utility to authenticate and get credentials:

Example:

> pub global run gcloud_user_auth get -i client.json -c creds.json -s 'https://www.googleapis.com/auth/drive https://www.googleapis.com/auth/spreadsheets'

Please go to the following URL and grant access:

https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=....

Paste the URL in a browser, authenticate with a Google user account.

The utility will write a credentials json file.

Note: The credentials file can be used as an authentiction utility input client json file.

Refreshing Credentials:

Example:

> pub global run gcloud_user_auth refresh -c creds.json

Using the Library

Dependencies:

The library is not available from pub.dartlang.org and must be had from the Github page instead.

To get the latest commited version (which may or may not be broken):

In your pubspec.yaml:

dependencies:
  gcloud_cl_user_auth:
    git: https://github.com/argentiapparatus/gcloud_cl_user_auth.dart.git

To get a specific release, tag or branch (which should not be broken):

dependencies:
  gcloud_cl_user_auth:
    git: https://github.com/argentiapparatus/gcloud_cl_user_auth.dart.git
    ref: some-identifer

See the Github page to find releases, tags and branches.

See Pub Dependencies - Github Packages for more details.

Imports:

import 'package:googleapis_auth/auth.dart';
import 'package:gcloud_cl_user_auth/auth_manager.dart';

main(List<String> args) async {

  String credsFile = args[0];
  AuthClient authClient = (await getUserAuthMgr(credsFile)).autoAuthClient;
  ...
}