oauth

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Token

type Token struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
	ExpiresIn    int    `json:"expires_in"`
	ExpiresAt    int64  `json:"expires_at"`
}

Token represents an OAuth2 token.

func (*Token) IsExpired

func (t *Token) IsExpired() bool

IsExpired checks if the token is expired or about to expire. It uses a buffer of max(expires_in/10, minRefreshBuffer) seconds to trigger proactive refresh before the token actually expires.

func (*Token) SetExpiresAt

func (t *Token) SetExpiresAt()

SetExpiresAt calculates and sets the ExpiresAt field based on the current time and ExpiresIn. If ExpiresIn is zero or negative and ExpiresAt is already set (e.g. from the provider response), it is left unchanged. If neither is usable, ExpiresAt is set to zero so IsExpired treats the token as immediately expired, forcing a refresh rather than guessing a lifetime.

func (*Token) SetExpiresIn

func (t *Token) SetExpiresIn()

SetExpiresIn calculates and sets the ExpiresIn field based on the ExpiresAt field.

Directories

Path Synopsis
Package copilot provides GitHub Copilot integration.
Package copilot provides GitHub Copilot integration.
Package hyper provides functions to handle Hyper device flow authentication.
Package hyper provides functions to handle Hyper device flow authentication.

Jump to

Keyboard shortcuts

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