Documentation ¶
Index ¶
- Constants
- func GenerateAuthURL(host, path string, config *AuthConfig) string
- func GetFromEnv(key string) (string, error)
- func GetFromEnvOrDefault(key, def string) string
- func GetNewSpotifyClient(ctx context.Context, a *AuthConfig, token *oauth2.Token) *spotify.Client
- func GetNewTwitchClient(a *AuthConfig) (*helix.Client, error)
- func GetUserIDFromRequest(r *http.Request) (string, error)
- func RefreshSpotifyToken(ctx context.Context, a *AuthConfig, token *oauth2.Token) (*oauth2.Token, error)
- type AuthConfig
Constants ¶
View Source
const ( // SpotifyAuthURL is the URL to Spotify Accounts Service's OAuth2 endpoint. SpotifyAuthURL = "https://accounts.spotify.com/authorize" //nolint:gosec // Mistakenly flagging an authorization URL // SpotifyTokenURL is the URL to the Spotify Accounts Service's OAuth2 // token endpoint. SpotifyTokenURL = "https://accounts.spotify.com/api/token" // SpotifyUserScope is the set of permissions required to access the necessary // Spotify APIs SpotifyUserScope = "user-modify-playback-state user-read-playback-state user-read-email" // TwitchUserScope is the set of permissions required to access the necessary // Twitch APIs TwitchUserScope = "channel:manage:redemptions" )
Variables ¶
This section is empty.
Functions ¶
func GenerateAuthURL ¶
func GenerateAuthURL(host, path string, config *AuthConfig) string
func GetFromEnv ¶
GetFromEnv tries to read an environment variable by key, and if: 1. the key does not exist: return an error 2. the key exists but the value is empty: return an error 3. the key exists AND the value is non-empty: return the value
func GetFromEnvOrDefault ¶
GetFromEnvOrDefault tries to get the environment variable by the given key, and if the var is empty/undefined, it returns the supplied default value instead.
func GetNewSpotifyClient ¶
func GetNewSpotifyClient(ctx context.Context, a *AuthConfig, token *oauth2.Token) *spotify.Client
func GetNewTwitchClient ¶
func GetNewTwitchClient(a *AuthConfig) (*helix.Client, error)
func RefreshSpotifyToken ¶
Types ¶
type AuthConfig ¶
type AuthConfig struct { ClientID string ClientSecret string Scope string RedirectURL string State string APIBaseURL string OAuth *oauth2.Config }
func LoadSpotifyConfigs ¶
func LoadSpotifyConfigs() (*AuthConfig, error)
func LoadTwitchConfigs ¶
func LoadTwitchConfigs() (*AuthConfig, error)
LoadTwitchConfigs reads from environment variables in order to populate configurations for creating a Twitch SDK client
Click to show internal directories.
Click to hide internal directories.