login

package
v1.1.25 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2025 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0

Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0

Index

Constants

View Source
const ClientCredentialsURL = "https://id.twitch.tv/oauth2/token?grant_type=client_credentials"
View Source
const DeviceCodeFlowGrantType = "urn:ietf:params:oauth:grant-type:device_code"
View Source
const DeviceCodeFlowTokenURL = "https://id.twitch.tv/oauth2/token"
View Source
const DeviceCodeFlowUrl = "https://id.twitch.tv/oauth2/device"
View Source
const RefreshTokenURL = "https://id.twitch.tv/oauth2/token?grant_type=refresh_token"
View Source
const RevokeTokenURL = "https://id.twitch.tv/oauth2/revoke"
View Source
const UserAuthorizeURL = "https://id.twitch.tv/oauth2/authorize?response_type=code"
View Source
const UserCredentialsURL = "https://id.twitch.tv/oauth2/token?grant_type=authorization_code"
View Source
const ValidateTokenURL = "https://id.twitch.tv/oauth2/validate"

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthorizationResponse

type AuthorizationResponse struct {
	AccessToken  string   `json:"access_token"`
	RefreshToken string   `json:"refresh_token"`
	ExpiresIn    int64    `json:"expires_in"`
	Scope        []string `json:"scope"`
	TokenType    string   `json:"token_type"`
}

type DeviceCodeFlowInitResponse added in v1.1.23

type DeviceCodeFlowInitResponse struct {
	DeviceCode      string `json:"device_code"`
	ExpiresIn       int    `json:"expires_in"`
	Interval        int    `json:"interval"`
	UserCode        string `json:"user_code"`
	VerificationUri string `json:"verification_uri"`
}

type LoginParameters

type LoginParameters struct {
	ClientID     string
	ClientSecret string
	Scopes       string
	ForceVerify  string
	Token        string
	URL          string
	RedirectURL  string
	AuthorizeURL string
}

type LoginResponse

type LoginResponse struct {
	Response  AuthorizationResponse
	ExpiresAt time.Time
}

func ClientCredentialsLogin

func ClientCredentialsLogin(p LoginParameters) (LoginResponse, error)

Sends `https://id.twitch.tv/oauth2/token?grant_type=client_credentials`. Generates a new App Access Token. Stores new token information in the CLI's config.

func CredentialsLogout

func CredentialsLogout(p LoginParameters) (LoginResponse, error)

Sends `https://id.twitch.tv/oauth2/revoke`. Revokes the provided token. Does not change the CLI's config at all.

func RefreshUserToken

func RefreshUserToken(p RefreshParameters, shouldStoreInConfig bool) (LoginResponse, error)

Sends `POST https://id.twitch.tv/oauth2/token`. Refreshes the provided token and optionally stores the result in the CLI's config.

func UserCredentialsLogin_AuthorizationCodeFlow added in v1.1.23

func UserCredentialsLogin_AuthorizationCodeFlow(p LoginParameters, webserverIP string, webserverPort string) (LoginResponse, error)

Uses Authorization Code Flow: https://dev.twitch.tv/docs/authentication/getting-tokens-oauth/#authorization-code-grant-flow Sends `https://id.twitch.tv/oauth2/token?grant_type=authorization_code`. Generates a new User Access Token, requiring the use of a web browser. Stores new token information in the CLI's config.

func UserCredentialsLogin_DeviceCodeFlow added in v1.1.23

func UserCredentialsLogin_DeviceCodeFlow(p LoginParameters) (LoginResponse, error)

Uses Device Code Flow: https://dev.twitch.tv/docs/authentication/getting-tokens-oauth/#device-code-grant-flow Generates a new User Access Token, requiring the use of a web browser from any device. Stores new token information in the CLI's config.

type RefreshParameters

type RefreshParameters struct {
	ClientID     string
	ClientSecret string
	RefreshToken string
	URL          string
}

type UserAuthorizationQueryResponse

type UserAuthorizationQueryResponse struct {
	Code  string
	State string
	Error error
}

type ValidateResponse added in v1.1.21

type ValidateResponse struct {
	ClientID  string   `json:"client_id"`
	UserLogin string   `json:"login"`
	UserID    string   `json:"user_id"`
	Scopes    []string `json:"scopes"`
	ExpiresIn int64    `json:"expires_in"`
}

func ValidateCredentials added in v1.1.21

func ValidateCredentials(p LoginParameters) (ValidateResponse, error)

Sends `GET https://id.twitch.tv/oauth2/validate`. Only validates. Does not store this information in the CLI's config.

Jump to

Keyboard shortcuts

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