library

command
v0.9.1-0...-c0ca104 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

README

Google Authenticator(GA) Prototype

Installation

To install the Google Authenticator prototype, run:

go get github.com/google/oauth2l/sgauth/example/library

Credentials

Currently Google Authenticator reads the service account JSON credential file from environment path:

  1. Go to the Pantheon UI (Prod|TestGaia)
  2. Enable the corresponding API if you haven't. (E.g. Service Management API in the example below)
  3. Create the service account key.
  4. Download the JSON credentials.
  5. Set $GOOGLE_APPLICATION_CREDENTIALS to the JSON path.

Command-line Usage

The demo main has the following usage pattern:

go run *.go protorpc|grpc --host {value} \
    [--aud {value}] [--scope {value}] [--api_name {value}] [--api_key {value}]

where:

  • protorpc|grpc [REQUIRED] is the selector between ProtobufRPC and gRPC protocols.
  • --host [REQUIRED] is the full host name of the API service. e.g. test-xxiang-library-example.sandbox.googleapis.com
  • [--scope] is the value of scope if you use OAuth2.0
  • [--aud] is the value of audience if you use client-signed JWT token. For more information about JWT token please read: Service account authorization without OAuth
  • [--api_key] is the Google API key.
  • [--api_name] is the full API name. e.g. google.example.library.v1.LibraryService. This field is only required when protorpc mode is selected.

Sample Usage

Work with Test GAIA

The following commands run the example with the Test GAIA instance so that your credential JSON needs to be generated from Test GAIA Pantheon. Currently the API service is hosted within a sandbox environment for prototyping purpose.

ProtoRPC
go run *.go protorpc --host test-xxiang-library-example.sandbox.googleapis.com \
--api_name google.example.library.v1.LibraryService
gRPC
go run *.go grpc --host test-xxiang-library-example.sandbox.googleapis.com \
--api_name google.example.library.v1.LibraryService 

Note: Both sample commands above uses JWT auth token by default. The audience is auto-computed based on the host and api_name. You can always set the audience explicitly by using the --aud flag.

OAuth

To authorize with OAuth, you only need specify the extra --scope flag, for example:

go run *.go grpc --scope https://www.googleapis.com/auth/xapi.zoo \
--host test-xxiang-library-example.sandbox.googleapis.com
API Key

To access the API with an API key:

go run *.go protorpc --host test-xxiang-library-example.sandbox.googleapis.com \
--api_name google.example.library.v1.LibraryService \
--api_key ANVavNK3PDM8pIprU7xmF4BlEvmKn37f4_N7D3k

or if you wanna use gRPC:

go run *.go grpc --host test-xxiang-library-example.sandbox.googleapis.com \
--api_key ANVavNK3PDM8pIprU7xmF4BlEvmKn37f4_N7D3k

Work with Prod GAIA

If you want to work with Prod GAIA, you can switch to use the public Library API service and everything else should be the same. e.g.

go run *.go grpc --host library-example.googleapis.com \
--scope https://www.googleapis.com/auth/xapi.zoo

Documentation

Overview

Copyright 2018 Google Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2018 Google Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2018 Google Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL