Files
plexpy/docs/sdks/authentication

Authentication

(authentication)

Overview

API Calls regarding authentication for Plex Media Server

Available Operations

get_transient_token

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

from plex_api_client import PlexAPI
from plex_api_client.models import operations

s = PlexAPI(
    access_token="<YOUR_API_KEY_HERE>",
    x_plex_client_identifier="gcgzw5rz2xovp84b4vha3a40",
)

res = s.authentication.get_transient_token(type_=operations.GetTransientTokenQueryParamType.DELEGATION, scope=operations.Scope.ALL)

if res is not None:
    # handle response
    pass

Parameters

Parameter Type Required Description
type operations.GetTransientTokenQueryParamType ✔️ delegation - This is the only supported type parameter.
scope operations.Scope ✔️ all - This is the only supported scope parameter.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

operations.GetTransientTokenResponse

Errors

Error Object Status Code Content Type
errors.GetTransientTokenResponseBody 400 application/json
errors.GetTransientTokenAuthenticationResponseBody 401 application/json
errors.SDKError 4xx-5xx /

get_source_connection_information

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

from plex_api_client import PlexAPI

s = PlexAPI(
    access_token="<YOUR_API_KEY_HERE>",
    x_plex_client_identifier="gcgzw5rz2xovp84b4vha3a40",
)

res = s.authentication.get_source_connection_information(source="server://client-identifier")

if res is not None:
    # handle response
    pass

Parameters

Parameter Type Required Description Example
source str ✔️ The source identifier with an included prefix. server://client-identifier
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

operations.GetSourceConnectionInformationResponse

Errors

Error Object Status Code Content Type
errors.GetSourceConnectionInformationResponseBody 400 application/json
errors.GetSourceConnectionInformationAuthenticationResponseBody 401 application/json
errors.SDKError 4xx-5xx /

get_user_details

Get the User data from the provided X-Plex-Token

Example Usage

from plex_api_client import PlexAPI

s = PlexAPI(
    access_token="<YOUR_API_KEY_HERE>",
    x_plex_client_identifier="gcgzw5rz2xovp84b4vha3a40",
)

res = s.authentication.get_user_details(x_plex_token="CV5xoxjTpFKUzBTShsaf")

if res.user_plex_account is not None:
    # handle response
    pass

Parameters

Parameter Type Required Description Example
x_plex_token str ✔️ Plex Authentication Token CV5xoxjTpFKUzBTShsaf
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.
server_url Optional[str] An optional server URL to use. http://localhost:8080

Response

operations.GetUserDetailsResponse

Errors

Error Object Status Code Content Type
errors.GetUserDetailsResponseBody 400 application/json
errors.GetUserDetailsAuthenticationResponseBody 401 application/json
errors.SDKError 4xx-5xx /

post_users_sign_in_data

Sign in user with username and password and return user data with Plex authentication token

Example Usage

from plex_api_client import PlexAPI

s = PlexAPI(
    x_plex_client_identifier="gcgzw5rz2xovp84b4vha3a40",
)

res = s.authentication.post_users_sign_in_data(x_plex_client_identifier="gcgzw5rz2xovp84b4vha3a40", request_body={
    "login": "username@email.com",
    "password": "password123",
    "verification_code": "123456",
})

if res.user_plex_account is not None:
    # handle response
    pass

Parameters

Parameter Type Required Description Example
x_plex_client_identifier Optional[str] 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)
gcgzw5rz2xovp84b4vha3a40
request_body Optional[operations.PostUsersSignInDataRequestBody] Login credentials
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.
server_url Optional[str] An optional server URL to use. http://localhost:8080

Response

operations.PostUsersSignInDataResponse

Errors

Error Object Status Code Content Type
errors.PostUsersSignInDataResponseBody 400 application/json
errors.PostUsersSignInDataAuthenticationResponseBody 401 application/json
errors.SDKError 4xx-5xx /