Documentation
¶
Index ¶
- func ClientFromAuthFile(ctx context.Context, authPath string) (*http.Client, error)
- func ClientFromAuthJSON(ctx context.Context, jsonContent string) (*http.Client, error)
- func Config() (*oauth2.Config, error)
- func ConfigFromAuthFile(authPath string) (*oauth2.Config, error)
- func EnsureAccessToken(ctx context.Context, source Source) (*http.Client, error)
- func ImportAuthFile(authPath, cacheFile string) error
- func Login(ctx context.Context, config *oauth2.Config) (*http.Client, error)
- func LoginWithCachePath(ctx context.Context, config *oauth2.Config, cacheFile string) (*http.Client, error)
- func LoginWithOptions(ctx context.Context, config *oauth2.Config, opts LoginOptions) (*http.Client, error)
- func Logout() error
- type LoginOptions
- type Source
- type SourceKind
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClientFromAuthFile ¶
ClientFromAuthFile builds an authenticated HTTP client from .clasprc.json. If refresh_token exists, this function refreshes token.access_token and persists it.
func ClientFromAuthJSON ¶ added in v0.2.7
ClientFromAuthJSON creates an authenticated HTTP client from raw .clasprc.json content (e.g. the value of the GLASP_AUTH environment variable). Refreshed tokens are not persisted to disk.
func ConfigFromAuthFile ¶
ConfigFromAuthFile returns an OAuth2 configuration loaded from a .clasprc.json file.
func EnsureAccessToken ¶
EnsureAccessToken resolves an authenticated HTTP client and refreshes token if needed.
func ImportAuthFile ¶
ImportAuthFile reads a .clasprc.json-style auth file and saves the token to cacheFile (.glasp/access.json). It returns an error if cacheFile already exists.
func LoginWithCachePath ¶
func LoginWithCachePath(ctx context.Context, config *oauth2.Config, cacheFile string) (*http.Client, error)
LoginWithCachePath performs the OAuth2 login flow using an explicit cache file path.
func LoginWithOptions ¶ added in v0.3.0
func LoginWithOptions(ctx context.Context, config *oauth2.Config, opts LoginOptions) (*http.Client, error)
LoginWithOptions performs the OAuth2 login flow with explicit options.
Types ¶
type LoginOptions ¶ added in v0.3.0
type LoginOptions struct {
// PKCE enables PKCE (Proof Key for Code Exchange) for the OAuth code exchange.
PKCE bool
}
LoginOptions configures optional behavior of the interactive login flow.
type Source ¶
type Source struct {
Kind SourceKind
Path string // used by SourceKindProjectCache and SourceKindAuthFile
Content string // raw JSON content, used by SourceKindAuthJSON
}
Source represents a resolved authentication source.
func ResolveAuthSource ¶
ResolveAuthSource chooses auth source by CLI input. If authPath is provided, .clasprc.json is used; otherwise project-local cache is used.
type SourceKind ¶
type SourceKind string
SourceKind identifies where authentication material is loaded from.
const ( SourceKindProjectCache SourceKind = "project_cache" SourceKindAuthFile SourceKind = "auth_file" // SourceKindAuthJSON is used when auth credentials are provided as raw // JSON content (e.g. via the GLASP_AUTH environment variable) rather // than a file path. SourceKindAuthJSON SourceKind = "auth_json" )