config

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package config resolves settings from flags, environment and config file.

Index

Constants

View Source
const DefaultRedirectURI = "http://127.0.0.1:8888/callback"

DefaultRedirectURI is the loopback callback `spotify auth login` listens on.

It must be registered verbatim in the Spotify dashboard. Spotify requires HTTPS for redirect URIs with one exception — a loopback IP literal — so this is 127.0.0.1 and not localhost, which the dashboard rejects.

Variables

This section is empty.

Functions

func CallbackAddr

func CallbackAddr(redirectURI string) (addr, path string, err error)

CallbackAddr returns the host:port and path the login server should listen on.

The redirect URI is what Spotify sends the browser back to, so the listener has to match it exactly — parsing it here keeps the two from drifting when someone registers a different port.

func Dir

func Dir() (string, error)

Dir returns the directory holding the config file and token cache.

func Path

func Path() (string, error)

Path returns the config file location, honouring XDG_CONFIG_HOME.

func Save

func Save(clientID, redirectURI string) (string, error)

Save writes the client id and redirect uri with owner-only permissions. The client id is not a secret under PKCE — that is the point of PKCE — but 0600 keeps the file consistent with the token cache next to it.

Types

type Config

type Config struct {
	ClientID    string
	RedirectURI string
	AccessToken string
}

Config holds resolved settings. Precedence, highest first: flag → environment → config file → default.

AccessToken, when set, is a ready-to-use bearer token that bypasses the PKCE flow entirely — used by scripts that mint their own token, and by the tests. ClientID and RedirectURI drive the interactive login.

func Load

func Load(flagClientID, flagRedirectURI, flagToken string) (Config, error)

Load resolves configuration. A flag value of "" means the flag was not set.

Jump to

Keyboard shortcuts

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