# 401 when using the webapi as non-owner plex home user

**URL:** <https://forums.plex.tv/t/401-when-using-the-webapi-as-non-owner-plex-home-user/103382>\
**Category:** Dev/API Corner\
**Tags:** other-dev\
**Created:** [May 17, 2015, 7:02pm UTC](https://forums.plex.tv/t/401-when-using-the-webapi-as-non-owner-plex-home-user/103382 "2015-05-17T19:02:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sunscreem\_gmail.com](https://avatars.discourse-cdn.com/v4/letter/s/c67d28/32.png) [@sunscreem\_gmail.com](https://forums.plex.tv/u/sunscreem_gmail.com)\
**Post date:** [May 17, 2015, 7:02pm UTC](https://forums.plex.tv/t/401-when-using-the-webapi-as-non-owner-plex-home-user/103382/1 "2015-05-17T19:02:57Z")

</div>

The subject line says it all really.

&nbsp;

I can get an x-plex-token for one of my plex home users from plex.tv, but trying an operation such as listing the library sections as that user gives me a 401.

&nbsp;

Anyone had/solved this?

&nbsp;

I've just spent a while looking through plex2csv to see if those folks solved it but it looks like that code for that only needs the plex owner to work.

&nbsp;

(This may be a duplicate of [this similar unanswered question](https://forums.plex.tv/topic/145078-authentication-token-not-valid-for-non-owner-plex-home-users/?hl=%2Bplex+%2Bhome))

---

<div class="post-metadata">

**Author:** ![dane22](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/dane22/32/4389_2.png) [@dane22](https://forums.plex.tv/u/dane22)\
**Post date:** [May 17, 2015, 9:02pm UTC](https://forums.plex.tv/t/401-when-using-the-webapi-as-non-owner-plex-home-user/103382/2 "2015-05-17T21:02:59Z")

</div>

Start by sharing some code here.....And FUI, Plex2CSV just got all token code removed, since it no longer needed it, since it's now a pure local PMS app only, and only use the buildin framework&nbsp; ;)

---

<div class="post-metadata">

**Author:** ![sunscreem\_gmail.com](https://avatars.discourse-cdn.com/v4/letter/s/c67d28/32.png) [@sunscreem\_gmail.com](https://forums.plex.tv/u/sunscreem_gmail.com)\
**Post date:** [May 18, 2015, 9:09am UTC](https://forums.plex.tv/t/401-when-using-the-webapi-as-non-owner-plex-home-user/103382/3 "2015-05-18T09:09:11Z")

</div>

Thanks Dane:

```
$.ajax({
	headers:{
	  'Authorization' : 'Basic '+userpass, // I'm assuming this needs passed in again along with the token from plex.tv
	  'X-Plex-Client-Identifier' : 'RobsPlexWebClient-1',
	  'X-Plex-Product' : 'RobsPlexWebClient',
	  'X-Plex-Version' : '1',
	  'X-Plex-Device-Name' : 'RobsPlexWebClient-1',
	  'X-Plex-Token': authcode, // this is the token from plex.tv
	  'Accept' : 'application/json'
	},
 	type: 'get',
	url: 'http://192.168.0.14:32400/library/sections',
		success: function(result){
	 	$.each(result._children,function(count,child){
			$('#output').append(child.title+"
");
		});
	},
	error : function(xhr,textStatus,errorThrown){
	  $('#output').append('ERROR: '+xhr.status+' '+textStatus+' '+errorThrown+'
');
	}
});
```

---

<div class="post-metadata">

**Author:** ![dane22](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/dane22/32/4389_2.png) [@dane22](https://forums.plex.tv/u/dane22)\
**Post date:** [May 18, 2015, 8:02pm UTC](https://forums.plex.tv/t/401-when-using-the-webapi-as-non-owner-plex-home-user/103382/4 "2015-05-18T20:02:16Z")

</div>

First sign in as the owner with the token....

Then do a get towards:

[https://plex.tv/api/home/users](https://plex.tv/api/home/users)

Find the user you wanna sign in as, and send the following, and still with your token in the header as a POST

[https://plex.tv/api/home/users/\<ID](https://plex.tv/api/home/users/)of Home User\>/switch

(Here the other std. header stuff also needs to be present, like the X-Plex-Client-Identifier)

Above should return a token you can use for further access, like you would with a regular token

/Tommy

---

<div class="post-metadata">

**Author:** ![mcneishh](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/mcneishh/32/179499_2.png) [@mcneishh](https://forums.plex.tv/u/mcneishh)\
**Post date:** [February 20, 2016, 4:36am UTC](https://forums.plex.tv/t/401-when-using-the-webapi-as-non-owner-plex-home-user/103382/5 "2016-02-20T04:36:04Z")

</div>

I guess you’ve figured this out by now, but for others who went looking like me 🙂  
There’s one more step to get the right token to use.

As above if you access the servers using the token returned from the switch you’ll get an unauthorised response.

You need to take the returned PlexTV token and check what resources the user has access to and use the respective token for the resource.

So after switching access this url with the users token:  
[https://plex.tv/api/resources?includeHttps=1&X-Plex-Token=](https://plex.tv/api/resources?includeHttps=1&X-Plex-Token=)

Then get the “accessToken” for the respective device(s).  
This is the token that should be then be used.

---

<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:** [January 8, 2020, 7:48pm UTC](https://forums.plex.tv/t/401-when-using-the-webapi-as-non-owner-plex-home-user/103382/6 "2020-01-08T19:48:57Z")

</div>


