auth

package
v0.0.0-...-beff5f5 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteCredentials

func DeleteCredentials() error

func DeleteToken

func DeleteToken() error

func NewClient

func NewClient(ctx context.Context, onUpdate func(newToken *Token) error) (*resty.Client, error)

NewClient creates a new Trakt client with automatic token management

func SaveCredentials

func SaveCredentials(creds *Credentials) error

func SaveToken

func SaveToken(token *Token) error

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

client is the authenticated HTTP client for Trakt API

type Credentials

type Credentials struct {
	ClientID     string `json:"client_id"`
	ClientSecret string `json:"client_secret"`
}

func LoadCredentials

func LoadCredentials() (*Credentials, error)

type DeviceCodeResponse

type DeviceCodeResponse struct {
	DeviceCode      string `json:"device_code"`
	UserCode        string `json:"user_code"`
	VerificationURL string `json:"verification_url"`
	ExpiresIn       int    `json:"expires_in"`
	Interval        int    `json:"interval"`
}

type Token

type Token struct {
	AccessToken  string   `json:"access_token"`
	RefreshToken string   `json:"refresh_token"`
	ExpiresIn    int      `json:"expires_in"`
	Scope        string   `json:"scope"`
	CreatedAt    UnixTime `json:"created_at"`
	TokenType    string   `json:"token_type"`
}

func LoadToken

func LoadToken() (*Token, error)

func RefreshToken

func RefreshToken(token *Token) (*Token, error)

func StartDeviceAuthFlow

func StartDeviceAuthFlow(ctx context.Context) (*Token, error)

func (*Token) IsExpired

func (t *Token) IsExpired() bool

type UnixTime

type UnixTime time.Time

func (UnixTime) MarshalJSON

func (t UnixTime) MarshalJSON() ([]byte, error)

func (UnixTime) Time

func (t UnixTime) Time() time.Time

func (*UnixTime) UnmarshalJSON

func (t *UnixTime) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

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