util

package
v0.0.0-...-5ab89ad Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Manages authenticating to Google and providing an OAuth2 token

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewImageUploadRequestFromFile

func NewImageUploadRequestFromFile(inputFilePath string,
	callback func(int64)) (*http.Request, error)

NewImageUploadRequestFromFile creates a file upload request. If callback parameter is specified, it will get called when data has been read (and thus submitted) from the reader.

func NewOAuth2Config

func NewOAuth2Config(clientID, clientSecret string) oauth2.Config

NewOAuth2Config creates a new OAuth2 configuration with client id + secret

Types

type Authenticator

type Authenticator struct {
	// contains filtered or unexported fields
}

Authenticator is our authenticator type. Construct using NewAuthenticator(). This class implements the Google OAuth2 authorization code flow; for more info, see: https://developers.google.com/actions/identity/oauth2-code-flow

func NewAuthenticator

func NewAuthenticator(clientID, clientSecret string) *Authenticator

NewAuthenticator creates a new Authenticator object with given client id + secret.

func (*Authenticator) Authorize

func (a *Authenticator) Authorize() (*oauth2.Token, *UserInfo, error)

Authorize synchronously waits for an access token.

type UserInfo

type UserInfo struct {
	ID        string `json:"id"`
	Name      string `json:"name"`
	GivenName string `json:"given_name"`
	LastName  string `json:"family_name"`
	Email     string `json:"email"`
}

UserInfo represents a Google user. The JSON field names are dictated by the Google userinfo API.

func GetUserInfo

func GetUserInfo(token *oauth2.Token) (*UserInfo, error)

GetUserInfo retrieves user information from the Google user info endpoint with token

Jump to

Keyboard shortcuts

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