# Authentication token not valid for non-owner Plex Home users

**URL:** <https://forums.plex.tv/t/authentication-token-not-valid-for-non-owner-plex-home-users/92631>\
**Category:** Dev/API Corner\
**Tags:** other-dev\
**Created:** [February 4, 2015, 11:47pm UTC](https://forums.plex.tv/t/authentication-token-not-valid-for-non-owner-plex-home-users/92631 "2015-02-04T23:47:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![svdlugt](https://avatars.discourse-cdn.com/v4/letter/s/9fc29f/32.png) [@svdlugt](https://forums.plex.tv/u/svdlugt)\
**Post date:** [February 4, 2015, 11:47pm UTC](https://forums.plex.tv/t/authentication-token-not-valid-for-non-owner-plex-home-users/92631/1 "2015-02-04T23:47:47Z")

</div>

I'm confused how Plex Home uses tokens to authenticate users and I can't get authentication for all users to work.&nbsp;

Using the following Python script I am able to use the username and password of a Plex user to obtain a token.

```
import httplib, urllib, base64
username = "insertanyusernamehere"
password = "insertcorrespondingpasswdhere"
base64string = base64.encodestring('%s:%s' % (username, password)).replace('
', '')
txdata = ""

headers={‘Authorization’: “Basic %s” % base64string,  
‘X-Plex-Client-Identifier’: “Test script”,  
‘X-Plex-Product’: “Test script 356546545”,  
‘X-Plex-Version’: “0.001”}

conn = httplib.HTTPSConnection(“[plex.tv](http://plex.tv)”)  
conn.request(“POST”,"/users/sign\_in.json",txdata,headers)  
response = conn.getresponse()  
print response.status, response.reason  
data = response.read()  
print str(data)  
conn.close()
```

The script returns some user info, including a token. Next, I try to use the token to access the Plex API with the following script:

import httplib, urllib, base64

```
token = "INSERTTOKENHERE"

txdata = “”

headers={‘X-Plex-Client-Identifier’: “Test script”,  
‘X-Plex-Product’: “Test script 356546545”,  
‘X-Plex-Version’: “0.001”,  
‘X-Plex-Token’: token}

conn = httplib.HTTPConnection(":32400")  
conn.request(“GET”,"/library",txdata,headers)  
response = conn.getresponse()  
print response.status, response.reason  
data = response.read()  
print str(data)  
conn.close()
```

When I enter the account credentials of the server's owner in the first script and insert the corresponding token into the second script, I get some info about the libraries on the Plex server, as expected. However, when I enter the credentials of any other Home user the first script returns a token successfully, but the second script returns a 401 Unauthorized error. &nbsp;

&nbsp;

Can someone tell me what I've been doing wrong?

&nbsp;

I followed the instructions in&nbsp;[this thread](https://forums.plex.tv/topic/129922-how-to-request-a-myplex-token-for-your-app/)&nbsp;and posted my question there too, but I received no help there.&nbsp;

---

<div class="post-metadata">

**Author:** ![chowmain\_software](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/chowmain_software/32/9761_2.png) [@chowmain\_software](https://forums.plex.tv/u/chowmain_software)\
**Post date:** [January 3, 2016, 5:11pm UTC](https://forums.plex.tv/t/authentication-token-not-valid-for-non-owner-plex-home-users/92631/2 "2016-01-03T17:11:24Z")

</div>

I am experiencing the same issue. Did you ever figure out what the problem was or the correct method to implement non owner accounts?

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/plex/original/3X/2/a/2acb9765406f63293d357b4ec509ec39aa28f2ad.png) [@system](https://forums.plex.tv/u/system)\
**Post date:** [December 21, 2019, 4:32am UTC](https://forums.plex.tv/t/authentication-token-not-valid-for-non-owner-plex-home-users/92631/3 "2019-12-21T04:32:47Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
