oauthhelper

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package oauthhelper provide an OAuth2 authentication and token management helper

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTokenBase64

func GetTokenBase64(token *oauth2.Token) (string, error)

GetTokenBase64 returns the Base64 representation of JSON token

func LoadTokenFromFile

func LoadTokenFromFile(file string) (*oauth2.Token, error)

LoadTokenFromFile loads an OAuth2 token from a JSON file

func StoreTokenToFile

func StoreTokenToFile(file string, token *oauth2.Token) error

StoreTokenToFile stores an OAuth2 token to a JSON file

Types

type Auth

type Auth struct {
	// Token holds the token that should be used for authentication (optional)
	// if the token is nil the callback func Authenticate will be called and after Authorization this token will be set
	// Store (and restore prior use) this token to avoid further authorization calls
	Token *oauth2.Token
	// ClientID  from https://console.developers.google.com/project/<your-project-id>/apiui/credential
	ClientID     string
	ClientSecret string
	Authenticate AuthenticateFunc
}

Auth defines the authentication parameters

func (*Auth) NewHTTPClient

func (auth *Auth) NewHTTPClient(ctx context.Context, scopes ...string) (*http.Client, error)

NewHTTPClient instantiates a new authentication client

type AuthenticateFunc

type AuthenticateFunc func(url string) (code string, err error)

AuthenticateFunc defines the signature of the authentication function used

Jump to

Keyboard shortcuts

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