Documentation
¶
Index ¶
- func DesktopFlow(ctx context.Context, clientID, clientSecret string, forceConsent bool) (*oauth2.Token, error)
- func OAuthConfig(clientID, clientSecret, redirectURL string) *oauth2.Config
- func RefreshIfNeeded(ctx context.Context, cfg *oauth2.Config, token *oauth2.Token) (*oauth2.Token, bool, error)
- type TokenStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DesktopFlow ¶
func DesktopFlow(ctx context.Context, clientID, clientSecret string, forceConsent bool) (*oauth2.Token, error)
DesktopFlow performs the OAuth2 desktop flow: 1. Start a local HTTP server on a random port 2. Open the auth URL in the browser 3. Wait for the redirect with the auth code 4. Exchange the code for a token
func OAuthConfig ¶
OAuthConfig creates the oauth2 config for YouTube APIs.
Types ¶
type TokenStatus ¶
type TokenStatus struct {
Valid bool `json:"valid"`
Expired bool `json:"expired"`
ExpiresAt time.Time `json:"expires_at,omitempty"`
HasRefresh bool `json:"has_refresh_token"`
}
TokenStatus describes the state of a token.
func CheckToken ¶
func CheckToken(token *oauth2.Token) TokenStatus
CheckToken returns the status of a token.
Click to show internal directories.
Click to hide internal directories.