Documentation ¶
Index ¶
- Variables
- func ExchangeCodeForToken(config *oauth2.Config, authCode string) (*oauth2.Token, error)
- func FileExists(filename string) bool
- func GenerateAPIKey() (string, error)
- func GenerateOauthURL(config *oauth2.Config, provider string, flowType string) (string, string, error)
- func GetOAuth2Config(provider string) (*oauth2.Config, error)
- func GetTokenFromRefreshToken(config *oauth2.Config, refreshToken string) (*oauth2.Token, error)
- func PollToken(config *oauth2.Config, deviceCode string) (*oauth2.Token, error)
- func RetrieveToken(provider string) (*oauth2.Token, error)
- func SaveToken(provider string, token *oauth2.Token) error
- func UpdateToken(provider string, token *oauth2.Token) error
- type OAuth2Config
Constants ¶
This section is empty.
Variables ¶
View Source
var ValidProviders = map[string]bool{ "google": true, "outlook": true, }
ValidProviders is a slice of valid OAuth2 providers
Functions ¶
func ExchangeCodeForToken ¶
ExchangeCodeForToken handles the redirect from the OAuth2 provider and exchanges the code for a token
func FileExists ¶
FileExists checks if a file exists and is not a directory before we
func GenerateAPIKey ¶
GenerateAPIKey generates an 32 byte API key in Hex format
func GenerateOauthURL ¶
func GenerateOauthURL(config *oauth2.Config, provider string, flowType string) (string, string, error)
GenerateOauthURL prints the URL to visit to authorize the application
func GetOAuth2Config ¶
GetOAuth2Config returns the OAuth2 config for the specified provider
func GetTokenFromRefreshToken ¶
GetTokenFromRefreshToken retrieves a token from a refresh token
func RetrieveToken ¶
RetrieveToken retrieves the OAuth token from redis.
Types ¶
type OAuth2Config ¶
type OAuth2Config struct { ClientID string `json:"client_id"` ClientSecret string `json:"client_secret"` RedirectURL string `json:"redirect_url"` Scopes []string `json:"scopes"` AuthURL string `json:"auth_url"` TokenURL string `json:"token_url"` }
OAuth2Config is a struct to hold the OAuth2 configuration
Click to show internal directories.
Click to hide internal directories.