auth

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2021 License: BSD-3-Clause, GPL-3.0, ISC Imports: 13 Imported by: 5

Documentation

Overview

Package auth provides a wrapper over the oauth2 library with additional helper functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FlushTokenFile

func FlushTokenFile(tokenFile string, token *oauth2.Token) error

FlushTokenFile encodes a Token object into JSON and writes it to the file tokenFile

func GetAuthCodeURL

func GetAuthCodeURL(config *oauth2.Config) (string, string)

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

func GetAuthTokenURL(config *oauth2.Config) (string, string)

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

func LoadTokenFile(tokenFile string) (*oauth2.Token, error)

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

func RetrieveTokenFile(config *oauth2.Config, file string) (*oauth2.Token, error)

RetrieveTokenFile is a helper function that calls LoadTokenFile, VerifyToken and FlushTokenFile.

func TokenExchange

func TokenExchange(config *oauth2.Config, authCode string) (*oauth2.Token, error)

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.

func VerifyToken

func VerifyToken(config *oauth2.Config, oldToken *oauth2.Token) *oauth2.Token

VerifyToken checks the input token for validity, and will return a refreshed token if it has expired. If the token is still valid, will return the same token.

Types

This section is empty.

Jump to

Keyboard shortcuts

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