declare(strict_types=1);
require 'vendor/autoload.php';
use LukeHagar\Plex_API;
use LukeHagar\Plex_API\Models\Operations;
$sdk = Plex_API\PlexAPI::builder()->build();
$request = new Operations\PostUsersSignInDataRequest(
clientID: '3381b62b-9ab7-4e37-827b-203e9809eb58',
clientName: 'Plex for Roku',
deviceNickname: 'Roku 3',
clientVersion: '2.4.1',
platform: 'Roku',
requestBody: new Operations\PostUsersSignInDataRequestBody(
login: 'username@email.com',
password: 'password123',
verificationCode: '123456',
),
);
$response = $sdk->authentication->postUsersSignInData(
request: $request
);
if ($response->userPlexAccount !== null) {
// handle response
}require 'plex_ruby_sdk'
s = ::PlexRubySDK::PlexAPI.new
req = Models::Operations::PostUsersSignInDataRequest.new(
client_id: "3381b62b-9ab7-4e37-827b-203e9809eb58",
client_name: "Plex for Roku",
device_nickname: "Roku 3",
client_version: "2.4.1",
platform: "Roku",
request_body: Models::Operations::PostUsersSignInDataRequestBody.new(
login: "username@email.com",
password: "password123",
verification_code: "123456",
),
)
res = s.authentication.post_users_sign_in_data(req)
if ! res.user_plex_account.nil?
# handle response
endpackage main
import(
"context"
"github.com/LukeHagar/plexgo/models/components"
"github.com/LukeHagar/plexgo"
"github.com/LukeHagar/plexgo/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := plexgo.New(
plexgo.WithAccepts(components.AcceptsApplicationXML),
plexgo.WithClientIdentifier("3381b62b-9ab7-4e37-827b-203e9809eb58"),
plexgo.WithProduct("Plex for Roku"),
plexgo.WithVersion("2.4.1"),
plexgo.WithPlatform("Roku"),
plexgo.WithPlatformVersion("4.3 build 1057"),
plexgo.WithDevice("Roku 3"),
plexgo.WithModel("4200X"),
plexgo.WithDeviceVendor("Roku"),
plexgo.WithDeviceName("Living Room TV"),
plexgo.WithMarketplace("googlePlay"),
)
res, err := s.Authentication.PostUsersSignInData(ctx, operations.PostUsersSignInDataRequest{
RequestBody: &operations.PostUsersSignInDataRequestBody{
Login: "username@email.com",
Password: "password123",
VerificationCode: plexgo.Pointer("123456"),
},
})
if err != nil {
log.Fatal(err)
}
if res.UserPlexAccount != nil {
// handle response
}
}package hello.world;
import dev.plexapi.sdk.PlexAPI;
import dev.plexapi.sdk.models.errors.PostUsersSignInDataBadRequest;
import dev.plexapi.sdk.models.errors.PostUsersSignInDataUnauthorized;
import dev.plexapi.sdk.models.operations.*;
import dev.plexapi.sdk.models.shared.Accepts;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws PostUsersSignInDataBadRequest, PostUsersSignInDataUnauthorized, Exception {
PlexAPI sdk = PlexAPI.builder()
.accepts(Accepts.APPLICATION_XML)
.clientIdentifier("abc123")
.product("Plex for Roku")
.version("2.4.1")
.platform("Roku")
.platformVersion("4.3 build 1057")
.device("Roku 3")
.model("4200X")
.deviceVendor("Roku")
.deviceName("Living Room TV")
.marketplace("googlePlay")
.build();
PostUsersSignInDataRequest req = PostUsersSignInDataRequest.builder()
.requestBody(PostUsersSignInDataRequestBody.builder()
.login("username@email.com")
.password("password123")
.verificationCode("123456")
.build())
.build();
PostUsersSignInDataResponse res = sdk.authentication().postUsersSignInData()
.request(req)
.call();
if (res.userPlexAccount().isPresent()) {
// handle response
}
}
}import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/models/shared";
const plexAPI = new PlexAPI({
accepts: Accepts.ApplicationXml,
clientIdentifier: "3381b62b-9ab7-4e37-827b-203e9809eb58",
product: "Plex for Roku",
version: "2.4.1",
platform: "Roku",
platformVersion: "4.3 build 1057",
device: "Roku 3",
model: "4200X",
deviceVendor: "Roku",
deviceName: "Living Room TV",
marketplace: "googlePlay",
});
async function run() {
const result = await plexAPI.authentication.postUsersSignInData({
requestBody: {
login: "username@email.com",
password: "password123",
verificationCode: "123456",
},
});
console.log(result);
}
run();curl --request POST \
--url https://plex.tv/api/v2/users/signin \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'X-Plex-Client-Identifier: <x-plex-client-identifier>' \
--data login=username@email.com \
--data password=password123 \
--data rememberMe=false \
--data verificationCode=123456import requests
url = "https://plex.tv/api/v2/users/signin"
payload = {
"login": "username@email.com",
"password": "password123",
"rememberMe": "false",
"verificationCode": "123456"
}
headers = {
"X-Plex-Client-Identifier": "<x-plex-client-identifier>",
"Content-Type": "application/x-www-form-urlencoded"
}
response = requests.post(url, data=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-Plex-Client-Identifier': '<x-plex-client-identifier>',
'Content-Type': 'application/x-www-form-urlencoded'
},
body: new URLSearchParams({
login: 'username@email.com',
password: 'password123',
rememberMe: 'false',
verificationCode: '123456'
})
};
fetch('https://plex.tv/api/v2/users/signin', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"authToken": "CxoUzBTSV5hsxjTpFKaf",
"email": "username@email.com",
"friendlyName": "friendlyUsername",
"hasPassword": true,
"id": 13692262,
"joinedAt": 1556281940,
"title": "UsernameTitle",
"twoFactorEnabled": false,
"username": "Username",
"uuid": "dae343c1f45beb4f",
"pastSubscriptions": [
{
"id": "<string>",
"mode": "<string>",
"renewsAt": 1556281940,
"endsAt": 1556281940,
"canceled": false,
"gracePeriod": false,
"onHold": false,
"canReactivate": false,
"canUpgrade": false,
"canDowngrade": false,
"canConvert": false,
"type": "plexpass",
"transfer": "<string>",
"state": "ended",
"billing": {
"internalPaymentMethod": {},
"paymentMethodId": 123
}
}
],
"trials": [
{}
],
"adsConsent": true,
"adsConsentReminderAt": 1556281940,
"adsConsentSetAt": 1556281940,
"anonymous": false,
"backupCodesCreated": false,
"confirmed": false,
"country": "US",
"emailOnlyAuth": false,
"experimentalFeatures": false,
"entitlements": "[]",
"guest": false,
"home": false,
"homeAdmin": false,
"homeSize": 1,
"locale": "<string>",
"mailingListActive": false,
"mailingListStatus": "active",
"maxHomeSize": 15,
"pin": "<string>",
"profile": {
"autoSelectAudio": true,
"defaultAudioLanguage": "ja",
"defaultSubtitleLanguage": "en",
"autoSelectSubtitle": 1,
"defaultSubtitleAccessibility": 1,
"defaultSubtitleForced": 1,
"watchedIndicator": 1,
"mediaReviewsVisibility": 1,
"defaultAudioAccessibility": 0,
"defaultAudioLanguages": null,
"defaultSubtitleLanguages": null,
"mediaReviewsLanguages": null
},
"protected": false,
"rememberExpiresAt": 1556281940,
"restricted": false,
"roles": [
"<string>"
],
"scrobbleTypes": "<string>",
"services": [
{
"identifier": "metadata-dev",
"endpoint": "https://epg.provider.plex.tv",
"token": "DjoMtqFAGRL1uVtCyF1dKIorTbShJeqv",
"secret": "<string>",
"status": "online"
}
],
"subscription": {
"features": [
"<string>"
],
"active": true,
"subscribedAt": "2021-04-12T18:21:12Z",
"status": "Inactive",
"paymentService": "<string>",
"plan": "<string>"
},
"subscriptionDescription": "<string>",
"subscriptions": [
{
"features": [
"<string>"
],
"active": true,
"subscribedAt": "2021-04-12T18:21:12Z",
"status": "Inactive",
"paymentService": "<string>",
"plan": "<string>"
}
],
"thumb": "https://plex.tv/users/a4f43c1ebfde43a5/avatar?c=8372075101",
"attributionPartner": null
}{
"errors": [
{
"code": 1000,
"message": "X-Plex-Client-Identifier is missing",
"status": 400
}
]
}{
"errors": [
{
"code": 1001,
"message": "User could not be authenticated",
"status": 401
}
]
}Get User Sign In Data
Sign in user with username and password and return user data with Plex authentication token
declare(strict_types=1);
require 'vendor/autoload.php';
use LukeHagar\Plex_API;
use LukeHagar\Plex_API\Models\Operations;
$sdk = Plex_API\PlexAPI::builder()->build();
$request = new Operations\PostUsersSignInDataRequest(
clientID: '3381b62b-9ab7-4e37-827b-203e9809eb58',
clientName: 'Plex for Roku',
deviceNickname: 'Roku 3',
clientVersion: '2.4.1',
platform: 'Roku',
requestBody: new Operations\PostUsersSignInDataRequestBody(
login: 'username@email.com',
password: 'password123',
verificationCode: '123456',
),
);
$response = $sdk->authentication->postUsersSignInData(
request: $request
);
if ($response->userPlexAccount !== null) {
// handle response
}require 'plex_ruby_sdk'
s = ::PlexRubySDK::PlexAPI.new
req = Models::Operations::PostUsersSignInDataRequest.new(
client_id: "3381b62b-9ab7-4e37-827b-203e9809eb58",
client_name: "Plex for Roku",
device_nickname: "Roku 3",
client_version: "2.4.1",
platform: "Roku",
request_body: Models::Operations::PostUsersSignInDataRequestBody.new(
login: "username@email.com",
password: "password123",
verification_code: "123456",
),
)
res = s.authentication.post_users_sign_in_data(req)
if ! res.user_plex_account.nil?
# handle response
endpackage main
import(
"context"
"github.com/LukeHagar/plexgo/models/components"
"github.com/LukeHagar/plexgo"
"github.com/LukeHagar/plexgo/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := plexgo.New(
plexgo.WithAccepts(components.AcceptsApplicationXML),
plexgo.WithClientIdentifier("3381b62b-9ab7-4e37-827b-203e9809eb58"),
plexgo.WithProduct("Plex for Roku"),
plexgo.WithVersion("2.4.1"),
plexgo.WithPlatform("Roku"),
plexgo.WithPlatformVersion("4.3 build 1057"),
plexgo.WithDevice("Roku 3"),
plexgo.WithModel("4200X"),
plexgo.WithDeviceVendor("Roku"),
plexgo.WithDeviceName("Living Room TV"),
plexgo.WithMarketplace("googlePlay"),
)
res, err := s.Authentication.PostUsersSignInData(ctx, operations.PostUsersSignInDataRequest{
RequestBody: &operations.PostUsersSignInDataRequestBody{
Login: "username@email.com",
Password: "password123",
VerificationCode: plexgo.Pointer("123456"),
},
})
if err != nil {
log.Fatal(err)
}
if res.UserPlexAccount != nil {
// handle response
}
}package hello.world;
import dev.plexapi.sdk.PlexAPI;
import dev.plexapi.sdk.models.errors.PostUsersSignInDataBadRequest;
import dev.plexapi.sdk.models.errors.PostUsersSignInDataUnauthorized;
import dev.plexapi.sdk.models.operations.*;
import dev.plexapi.sdk.models.shared.Accepts;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws PostUsersSignInDataBadRequest, PostUsersSignInDataUnauthorized, Exception {
PlexAPI sdk = PlexAPI.builder()
.accepts(Accepts.APPLICATION_XML)
.clientIdentifier("abc123")
.product("Plex for Roku")
.version("2.4.1")
.platform("Roku")
.platformVersion("4.3 build 1057")
.device("Roku 3")
.model("4200X")
.deviceVendor("Roku")
.deviceName("Living Room TV")
.marketplace("googlePlay")
.build();
PostUsersSignInDataRequest req = PostUsersSignInDataRequest.builder()
.requestBody(PostUsersSignInDataRequestBody.builder()
.login("username@email.com")
.password("password123")
.verificationCode("123456")
.build())
.build();
PostUsersSignInDataResponse res = sdk.authentication().postUsersSignInData()
.request(req)
.call();
if (res.userPlexAccount().isPresent()) {
// handle response
}
}
}import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/models/shared";
const plexAPI = new PlexAPI({
accepts: Accepts.ApplicationXml,
clientIdentifier: "3381b62b-9ab7-4e37-827b-203e9809eb58",
product: "Plex for Roku",
version: "2.4.1",
platform: "Roku",
platformVersion: "4.3 build 1057",
device: "Roku 3",
model: "4200X",
deviceVendor: "Roku",
deviceName: "Living Room TV",
marketplace: "googlePlay",
});
async function run() {
const result = await plexAPI.authentication.postUsersSignInData({
requestBody: {
login: "username@email.com",
password: "password123",
verificationCode: "123456",
},
});
console.log(result);
}
run();curl --request POST \
--url https://plex.tv/api/v2/users/signin \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'X-Plex-Client-Identifier: <x-plex-client-identifier>' \
--data login=username@email.com \
--data password=password123 \
--data rememberMe=false \
--data verificationCode=123456import requests
url = "https://plex.tv/api/v2/users/signin"
payload = {
"login": "username@email.com",
"password": "password123",
"rememberMe": "false",
"verificationCode": "123456"
}
headers = {
"X-Plex-Client-Identifier": "<x-plex-client-identifier>",
"Content-Type": "application/x-www-form-urlencoded"
}
response = requests.post(url, data=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-Plex-Client-Identifier': '<x-plex-client-identifier>',
'Content-Type': 'application/x-www-form-urlencoded'
},
body: new URLSearchParams({
login: 'username@email.com',
password: 'password123',
rememberMe: 'false',
verificationCode: '123456'
})
};
fetch('https://plex.tv/api/v2/users/signin', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"authToken": "CxoUzBTSV5hsxjTpFKaf",
"email": "username@email.com",
"friendlyName": "friendlyUsername",
"hasPassword": true,
"id": 13692262,
"joinedAt": 1556281940,
"title": "UsernameTitle",
"twoFactorEnabled": false,
"username": "Username",
"uuid": "dae343c1f45beb4f",
"pastSubscriptions": [
{
"id": "<string>",
"mode": "<string>",
"renewsAt": 1556281940,
"endsAt": 1556281940,
"canceled": false,
"gracePeriod": false,
"onHold": false,
"canReactivate": false,
"canUpgrade": false,
"canDowngrade": false,
"canConvert": false,
"type": "plexpass",
"transfer": "<string>",
"state": "ended",
"billing": {
"internalPaymentMethod": {},
"paymentMethodId": 123
}
}
],
"trials": [
{}
],
"adsConsent": true,
"adsConsentReminderAt": 1556281940,
"adsConsentSetAt": 1556281940,
"anonymous": false,
"backupCodesCreated": false,
"confirmed": false,
"country": "US",
"emailOnlyAuth": false,
"experimentalFeatures": false,
"entitlements": "[]",
"guest": false,
"home": false,
"homeAdmin": false,
"homeSize": 1,
"locale": "<string>",
"mailingListActive": false,
"mailingListStatus": "active",
"maxHomeSize": 15,
"pin": "<string>",
"profile": {
"autoSelectAudio": true,
"defaultAudioLanguage": "ja",
"defaultSubtitleLanguage": "en",
"autoSelectSubtitle": 1,
"defaultSubtitleAccessibility": 1,
"defaultSubtitleForced": 1,
"watchedIndicator": 1,
"mediaReviewsVisibility": 1,
"defaultAudioAccessibility": 0,
"defaultAudioLanguages": null,
"defaultSubtitleLanguages": null,
"mediaReviewsLanguages": null
},
"protected": false,
"rememberExpiresAt": 1556281940,
"restricted": false,
"roles": [
"<string>"
],
"scrobbleTypes": "<string>",
"services": [
{
"identifier": "metadata-dev",
"endpoint": "https://epg.provider.plex.tv",
"token": "DjoMtqFAGRL1uVtCyF1dKIorTbShJeqv",
"secret": "<string>",
"status": "online"
}
],
"subscription": {
"features": [
"<string>"
],
"active": true,
"subscribedAt": "2021-04-12T18:21:12Z",
"status": "Inactive",
"paymentService": "<string>",
"plan": "<string>"
},
"subscriptionDescription": "<string>",
"subscriptions": [
{
"features": [
"<string>"
],
"active": true,
"subscribedAt": "2021-04-12T18:21:12Z",
"status": "Inactive",
"paymentService": "<string>",
"plan": "<string>"
}
],
"thumb": "https://plex.tv/users/a4f43c1ebfde43a5/avatar?c=8372075101",
"attributionPartner": null
}{
"errors": [
{
"code": 1000,
"message": "X-Plex-Client-Identifier is missing",
"status": 400
}
]
}{
"errors": [
{
"code": 1001,
"message": "User could not be authenticated",
"status": 401
}
]
}Headers
Indicates the client accepts the indicated media types
application/json, application/xml An opaque identifier unique to the client
"abc123"
The name of the client product
"Plex for Roku"
The version of the client application
"2.4.1"
The platform of the client
"Roku"
The version of the platform
"4.3 build 1057"
A relatively friendly name for the client device
"Roku 3"
A potentially less friendly identifier for the device model
"4200X"
The device vendor
"Roku"
A friendly name for the client
"Living Room TV"
The marketplace on which the client application is distributed
"googlePlay"
Body
Login credentials
Response
Returns the user account data with a valid auth token
The account token
"CxoUzBTSV5hsxjTpFKaf"
The account email address
"username@email.com"
Your account full name
"friendlyUsername"
If the account has a password
The Plex account ID
13692262
Unix epoch datetime in seconds
1556281940
The title of the account (username or friendly name)
"UsernameTitle"
If two-factor authentication is enabled
The account username
"Username"
The account UUID
"dae343c1f45beb4f"
Show child attributes
Show child attributes
Unknown
Unix epoch datetime in seconds
1556281940
Unix epoch datetime in seconds
1556281940
Unknown
If the two-factor authentication backup codes have been created
If the account has been confirmed
The account country
2"US"
If login with email only is enabled
If experimental features are enabled
List of devices your allowed to use with this account
"[]"
If the account is a Plex Home guest user
If the account is a Plex Home user
If the account is the Plex Home admin
The number of accounts in the Plex Home
1
The account locale
If you are subscribed to the Plex newsletter
Your current mailing list status
active, unsubscribed, removed "active"
The maximum number of accounts allowed in the Plex Home
15
[Might be removed] The hashed Plex Home PIN
Show child attributes
Show child attributes
If the account has a Plex Home PIN enabled
Unix epoch datetime in seconds
1556281940
If the account is a Plex Home managed user
[Might be removed] List of account roles. Plexpass membership listed here
Unknown
Show child attributes
Show child attributes
If the account's Plex Pass subscription is active
Show child attributes
Show child attributes
Description of the Plex Pass subscription
Show child attributes
Show child attributes
URL of the account thumbnail
"https://plex.tv/users/a4f43c1ebfde43a5/avatar?c=8372075101"
null
Was this page helpful?