google

package
v0.0.0-...-e4d3a07 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCallbackHandler

func NewCallbackHandler(cfg *oauth2.Config, ckCfg *autho.CookieConfig, errHandler, terminalHandler http.Handler) http.Handler

NewCallbackHandler is a helper function that constructs a new callback handler using the default token handler google.NewTokenHandler() wrapped arround the default google.NewUserHandler().

This method saves allot of boilerplate. For more customisable handlers construct your own callback handler by wrapping your own specific token handler around your own specific user handler.

func NewLoginHandler

func NewLoginHandler(cfg *oauth2.Config, ckCfg *autho.CookieConfig) http.Handler

NewLoginHandler creates a new LoginHandler which is resposible for setting a random value (state) to the state cookie. Afterwards the login handler is also responsible for redirecting the user to the provider for the users grant.

func NewTokenHandler

func NewTokenHandler(cfg *oauth2.Config, ckCfg *autho.CookieConfig, errHandler, callbackHandler http.Handler) http.Handler

NewTokenHandler creates a new TokenHandler which is the first handler in the chain responding to the callback from the provider, it is responsible for parsing the response for auth code and state then comparing the cookie state with the request state. Following the parsing the TokenHandler performs the token exchange and adds the token to the request context, calling on success the UserHandler.

func NewUserHandler

func NewUserHandler(cfg *oauth2.Config, errHandler, terminalHandler http.Handler) http.Handler

NewUserHandler creates a new google UserHandler resposnible for using the tokens provided by the TokenHandler in exchange for the users resource. The user resource is set under the request context.

user, ok := autho.UserFromContext(r.Context()).(*oauth2.Userinfo)

The UserModel used by default by the google.NewUserHandler is: https://pkg.go.dev/google.golang.org/api/oauth2/v2#Userinfo

Types

This section is empty.

Jump to

Keyboard shortcuts

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