mirror of
https://github.com/LukeHagar/plexjs.git
synced 2025-12-06 12:37:46 +00:00
12 KiB
12 KiB
Authentication
(authentication)
Overview
API Calls regarding authentication for Plex Media Server
Available Operations
- getTransientToken - Get a Transient Token.
- getSourceConnectionInformation - Get Source Connection Information
getTransientToken
This endpoint provides the caller with a temporary token with the same access level as the caller's token. These tokens are valid for up to 48 hours and are destroyed if the server instance is restarted.
Example Usage
import { GetTransientTokenQueryParamType, PlexAPI, Scope } from "@lukehagar/plexjs";
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "Postman",
});
async function run() {
const result = await plexAPI.authentication.getTransientToken(GetTransientTokenQueryParamType.Delegation, Scope.All);
// Handle the result
console.log(result)
}
run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
type |
models.GetTransientTokenQueryParamType | ✔️ | delegation - This is the only supported type parameter. |
scope |
models.Scope | ✔️ | all - This is the only supported scope parameter. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
Response
Promise<models.GetTransientTokenResponse>
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| models.GetTransientTokenResponseBody | 401 | application/json |
| models.SDKError | 4xx-5xx | / |
getSourceConnectionInformation
If a caller requires connection details and a transient token for a source that is known to the server, for example a cloud media provider or shared PMS, then this endpoint can be called. This endpoint is only accessible with either an admin token or a valid transient token generated from an admin token. Note: requires Plex Media Server >= 1.15.4.
Example Usage
import { PlexAPI } from "@lukehagar/plexjs";
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "Postman",
});
async function run() {
const result = await plexAPI.authentication.getSourceConnectionInformation("server://client-identifier");
// Handle the result
console.log(result)
}
run();
Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
source |
string | ✔️ | The source identifier with an included prefix. | [object Object] |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. | |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
Response
Promise<models.GetSourceConnectionInformationResponse>
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| models.GetSourceConnectionInformationResponseBody | 401 | application/json |
| models.SDKError | 4xx-5xx | / |