auth

package
v0.0.0-...-aea8ea7 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

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

func OAuthConfig(clientID, clientSecret, redirectURL string) *oauth2.Config

OAuthConfig creates the oauth2 config for YouTube APIs.

func RefreshIfNeeded

func RefreshIfNeeded(ctx context.Context, cfg *oauth2.Config, token *oauth2.Token) (*oauth2.Token, bool, error)

RefreshIfNeeded refreshes the token if it's expired.

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.

Jump to

Keyboard shortcuts

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