Documentation ¶
Index ¶
- func GenerateAuthURL(appName, clientID, pinCode string, extraOpts ExtraAuthURLOptions) (string, error)
- func GetPlexPIN(appName, clientID string) (pinID int, pinCode string, err error)
- func GetPlexPINContext(ctx context.Context, appName, clientID string) (pinID int, pinCode string, err error)
- func IsTokenValid(appName, clientID, token string) (bool, error)
- func IsTokenValidContext(ctx context.Context, appName, clientID, token string) (bool, error)
- func PollForAuthToken(inCtx context.Context, pinID int, pinCode, clientID string) (string, error)
- type ExtraAuthURLOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateAuthURL ¶
func GenerateAuthURL(appName, clientID, pinCode string, extraOpts ExtraAuthURLOptions) (string, error)
GenerateAuthURL creates an authorization link that a user can visit to authorize an application. The application name, unique client id, and pin code are all required for the link to work.
To send extra info that can be displayed on the Authorized Devices dashboard, the ExtraAuthURLOptions struct can be used.
func GetPlexPIN ¶
GetPlexPIN requests a new claimable pin from the Plex API which can be used to authenticate a user.
func GetPlexPINContext ¶
func GetPlexPINContext(ctx context.Context, appName, clientID string) (pinID int, pinCode string, err error)
GetPlexPINContext requests a new claimable pin from the Plex API which can be used to authenticate a user.
func IsTokenValid ¶
IsTokenValid checks if a Plex token is valid using the Plex API.
func IsTokenValidContext ¶
IsTokenValidContext checks if a Plex token is valid using the Plex API and a custom request context.
func PollForAuthToken ¶
PollForAuthToken gets a new auth token by waiting for the user to authenticate the pin in a web browser.
A custom context is required, but will be restricted to a 30 minute timeout. This is because Plex pins are only valid for 30 minutes.
Types ¶
type ExtraAuthURLOptions ¶
type ExtraAuthURLOptions struct { AppVersion string DeviceName string Device string // Small descriptor of the device Platform string // Determines what icon is used in the authorized devices dashboard. PlatformVersion string }
ExtraAuthURLOptions provides a way to provide extra metadata about the device being authorized. Any zero-value will be omitted from the final authentication url.