example

command
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2019 License: Apache-2.0 Imports: 15 Imported by: 0

README

oauth2cli example

This is an example application using oauth2cli.

Getting Started

Setup your API access:

  1. Open https://console.cloud.google.com/apis/credentials
  2. Create an OAuth client ID where the application type is other.

Build and run the application:

% go build
% ./example -client-id xxx.apps.googleusercontent.com -client-secret xxxxxxxx
2019/10/03 00:01:35 Open http://localhost:53753
2019/10/03 00:01:40 You got a valid token until 2019-10-03 01:01:40.083238 +0900 JST m=+3604.526750517

It will automatically open the browser and you can log in to Google.

Use a TLS certificate

You can set a certificate and key for the local server.

./example -client-id xxx.apps.googleusercontent.com -client-secret xxxxxxxx \
  -local-server-cert ../testdata/cert.pem -local-server-key ../testdata/cert-key.pem
Use PKCE

This example uses the Okta. You need to setup your application with PKCE on your account.

./example -pkce -scopes email,openid \
  -auth-url https://xxxxxxxx.okta.com/oauth2/default/v1/authorize \
  -token-url https://xxxxxxxx.okta.com/oauth2/default/v1/token \
  -client-id xxxxxxxx

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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