plexauth

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

README

Plex Authentication (in Go!)

GoDoc

Installation

As a Go library: go get github.com/BrenekH/go-plexauth

As a CLI: go install github.com/BrenekH/go-plexauth/cli@latest

Documentation

Index

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

func GetPlexPIN(appName, clientID string) (pinID int, pinCode string, err error)

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

func IsTokenValid(appName, clientID, token string) (bool, error)

IsTokenValid checks if a Plex token is valid using the Plex API.

func IsTokenValidContext

func IsTokenValidContext(ctx context.Context, appName, clientID, token string) (bool, error)

IsTokenValidContext checks if a Plex token is valid using the Plex API and a custom request context.

func PollForAuthToken

func PollForAuthToken(inCtx context.Context, pinID int, pinCode, clientID string) (string, error)

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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