mirror of
https://github.com/LukeHagar/plexgo.git
synced 2025-12-06 04:20:46 +00:00
12 KiB
12 KiB
Plex
(Plex)
Overview
API Calls that perform operations directly against https://Plex.tv
Available Operations
GetPin
Retrieve a Pin from Plex.tv for authentication flows
Example Usage
package main
import(
"github.com/LukeHagar/plexgo"
"context"
"log"
)
func main() {
s := plexgo.New(
plexgo.WithXPlexClientIdentifier("Postman"),
)
var strong *bool = plexgo.Bool(false)
var xPlexClientIdentifier *string = plexgo.String("Postman")
ctx := context.Background()
res, err := s.Plex.GetPin(ctx, strong, xPlexClientIdentifier)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. | |
strong |
*bool | ➖ | Determines the kind of code returned by the API call Strong codes are used for Pin authentication flows Non-Strong codes are used for Plex.tv/link |
|
xPlexClientIdentifier |
*string | ➖ | The unique identifier for the client application This is used to track the client application and its usage (UUID, serial number, or other number unique per device) |
Postman |
opts |
[]operations.Option | ➖ | The options for this request. |
Response
*operations.GetPinResponse, error
| Error Object | Status Code | Content Type |
|---|---|---|
| sdkerrors.GetPinResponseBody | 400 | application/json |
| sdkerrors.SDKError | 4xx-5xx | / |
GetToken
Retrieve an Access Token from Plex.tv after the Pin has already been authenticated
Example Usage
package main
import(
"github.com/LukeHagar/plexgo"
"context"
"log"
)
func main() {
s := plexgo.New(
plexgo.WithXPlexClientIdentifier("Postman"),
)
var pinID string = "<value>"
var xPlexClientIdentifier *string = plexgo.String("Postman")
ctx := context.Background()
res, err := s.Plex.GetToken(ctx, pinID, xPlexClientIdentifier)
if err != nil {
log.Fatal(err)
}
if res != nil {
// handle response
}
}
Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. | |
pinID |
string | ✔️ | The PinID to retrieve an access token for | |
xPlexClientIdentifier |
*string | ➖ | The unique identifier for the client application This is used to track the client application and its usage (UUID, serial number, or other number unique per device) |
Postman |
opts |
[]operations.Option | ➖ | The options for this request. |
Response
*operations.GetTokenResponse, error
| Error Object | Status Code | Content Type |
|---|---|---|
| sdkerrors.GetTokenResponseBody | 400 | application/json |
| sdkerrors.SDKError | 4xx-5xx | / |