Documentation ¶
Overview ¶
Package auth provides a wrapper over the oauth2 library with additional helper functions.
Index ¶
- func FlushTokenFile(tokenFile string, token *oauth2.Token) error
- func GetAuthCodeURL(config *oauth2.Config) (string, string)
- func GetAuthTokenURL(config *oauth2.Config) (string, string)
- func LoadTokenFile(tokenFile string) (*oauth2.Token, error)
- func NewUserAuth(clientID string, clientSecret string, redirectURI string, scopes *[]string) (*oauth2.Config, error)
- func RetrieveTokenFile(config *oauth2.Config, file string) (*oauth2.Token, error)
- func TokenExchange(config *oauth2.Config, authCode string) (*oauth2.Token, error)
- func VerifyToken(config *oauth2.Config, oldToken *oauth2.Token) *oauth2.Token
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FlushTokenFile ¶
FlushTokenFile encodes a Token object into JSON and writes it to the file tokenFile
func GetAuthCodeURL ¶
GetAuthCodeURL returns a URL to send to the end user for them to access as well as the state string embedded into the URL. This is for OAuth User Token Flows. Ensure that this state string matches the value received at the redirect URI.
func GetAuthTokenURL ¶ added in v0.2.2
GetAuthTokenURL returns a URL to send to the end user for them to access as well as the state string embedded into the URL. This is for OAuth Implicit Flows. Ensure that this state string matches the value received at the redirect URI.
func LoadTokenFile ¶
LoadTokenFile decodes a Token object from file tokenFile
func NewUserAuth ¶
func NewUserAuth(clientID string, clientSecret string, redirectURI string, scopes *[]string) (*oauth2.Config, error)
NewUserAuth creates and returns OAuth2 configuration object with the twitch endpoint. Also returns a URL to be sent to the user used to initiate authentication.
func RetrieveTokenFile ¶
RetrieveTokenFile is a helper function that calls LoadTokenFile, VerifyToken and FlushTokenFile.
func TokenExchange ¶
TokenExchange conducts the exchange to turn an auth code into a user token. The OAuth2 config used to create the auth code must be the same.
Types ¶
This section is empty.