# HTTP.SetPassword Error

**URL:** <https://forums.plex.tv/t/http-setpassword-error/24935>\
**Category:** Dev/API Corner\
**Tags:** other-dev\
**Created:** [December 11, 2012, 6:07pm UTC](https://forums.plex.tv/t/http-setpassword-error/24935 "2012-12-11T18:07:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mst1228](https://avatars.discourse-cdn.com/v4/letter/m/f17d59/32.png) [@mst1228](https://forums.plex.tv/u/mst1228)\
**Post date:** [December 11, 2012, 6:07pm UTC](https://forums.plex.tv/t/http-setpassword-error/24935/1 "2012-12-11T18:07:12Z")

</div>

Receiving error in log
Hi. I'm trying to use HTTP.Request to get some info from a website. I read some other threads about people trying to make plugins to manage torrent downloads from within the PLEX interface but decided to give it a go myself. The HTTP request will just be returning some info that I will use to populate a list, not media to play. Here's the small code I have now:  

```auto

##################################################<br />
<br />
VIDEO_PREFIX = "/video/ptp"<br />
<br />
NAME = "Pass The Popcorn"<br />
<br />
ART = 'art-default.jpg'<br />
ICON = 'icon-default.png'<br />
<br />
##################################################<br />
<br />
def Start():<br />
<br />
	Plugin.AddPrefixHandler(VIDEO_PREFIX, MainMenu, NAME, ICON, ART)<br />
	Plugin.AddViewGroup("List", viewMode = "List", mediaType = "items")<br />
	<br />
	MediaContainer.art = R(ART)<br />
	MediaContainer.title1 = NAME<br />
	MediaContainer.viewGroup = "List"<br />
	DirectoryItem.thumb = R(ICON)<br />
	<br />
def MainMenu():<br />
	<br />
	dir = MediaContainer(viewMode="List")<br />
	dir.Append(Function(DirectoryItem(MostRecent, "Most Recent")))<br />
	dir.Append(PrefsItem(L('Preferences'), thumb=R('icon-default.png')))<br />
	<br />
	return dir<br />
	<br />
def MostRecent(sender):<br />
	<br />
	u = Prefs['username']<br />
	p = Prefs['password']<br />
	<br />
	req = HTTP.Request('http://passthepopcorn.me/torrents.php')<br />
	HTTP.SetPassword('http://passthepopcorn.me', u, p)<br />
	req.load()<br />
	res = req.content<br />
	<br />
	Log(res)<br />
	<br />
	return MessageContainer('Result', L(res))

```

  
  
Right now I'm kinda just hacking around and sending the result of the HTTP.Request to a MessageContainer to see if it worked. This works when I DO NOT include the line to HTTP.SetPassword, but when I do include that line, I receive an error in my log. Here's the line in the log that is of note:  
  

```auto

2012-12-11 02:14:41,676 (-4faed000) : CRITICAL (sandbox:303) - Exception when calling function 'MostRecent' (most recent call last):<br />
  File "/Users/thorson/Library/Application Support/Plex Media Server/Plug-ins/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/code/sandbox.py", line 294, in call_named_function<br />
    result = f(*args, **kwargs)<br />
  File "/Users/thorson/Library/Application Support/Plex Media Server/Plug-ins/passThePopcorn.bundle/Contents/Code/ __init__.py", line 38, in MostRecent<br />
    HTTP.SetPassword('http://passthepopcorn.me', u, p)<br />
  File "/Users/thorson/Library/Application Support/Plex Media Server/Plug-ins/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/api/base.py", line 55, in func<br />
    return f(self, *args, **kwargs)<br />
  File "/Users/thorson/Library/Application Support/Plex Media Server/Plug-ins/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/api/networkkit.py", line 218, in SetPassword<br />
    return self._core.networking.set_http_password(url, username, password, realm)<br />
  File "/Users/thorson/Library/Application Support/Plex Media Server/Plug-ins/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/components/networking.py", line 420, in set_http_password<br />
    if _global_http_auth_enabled:<br />
NameError: global name '_global_http_auth_enabled' is not defined

```

  
  
Let me know if you have any ideas or if I'm going about this all wrong. Thanks in advance for any assistance, I really appreciate it.

---

<div class="post-metadata">

**Author:** ![mst1228](https://avatars.discourse-cdn.com/v4/letter/m/f17d59/32.png) [@mst1228](https://forums.plex.tv/u/mst1228)\
**Post date:** [December 11, 2012, 10:50pm UTC](https://forums.plex.tv/t/http-setpassword-error/24935/2 "2012-12-11T22:50:55Z")

</div>

Ok I was definitely going about it the wrong way. I think HTTP.SetPassword method is for password protected web directories maybe(?), I needed to actually POST my username and password in order to login to this website. I checked out the Vimeo plugin example on GitHub and found some good direction there.  
  
  
  
I know it’s been mentioned around here before, but for others that are looking for a good way to visualize network traffic/requests/responses, Charles Proxy is an absolutely invaluable tool.

---

<div class="post-metadata">

**Author:** ![jourh](https://avatars.discourse-cdn.com/v4/letter/j/8c91f0/32.png) [@jourh](https://forums.plex.tv/u/jourh)\
**Post date:** [August 24, 2013, 7:13pm UTC](https://forums.plex.tv/t/http-setpassword-error/24935/3 "2013-08-24T19:13:18Z")

</div>

I'm getting this error, and I actually DO need to use HTTP auth. Anyone have any thoughts?

---

<div class="post-metadata">

**Author:** ![jourh](https://avatars.discourse-cdn.com/v4/letter/j/8c91f0/32.png) [@jourh](https://forums.plex.tv/u/jourh)\
**Post date:** [October 1, 2013, 3:23pm UTC](https://forums.plex.tv/t/http-setpassword-error/24935/4 "2013-10-01T15:23:22Z")

</div>

Figured it out... minor coding error in &nbsp;~/Library/Application Support/Plex Media Server/Plug-ins/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/components/networking.py

In the set\_http\_password function, it has

&nbsp;

&nbsp; &nbsp; if \_global\_http\_auth\_enabled:

&nbsp;

That needs to be:

&nbsp;

&nbsp; &nbsp; if **self.** \_global\_http\_auth\_enabled:

&nbsp;

Endeavoring to file a bug report...

---

<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 20, 2019, 10:33pm UTC](https://forums.plex.tv/t/http-setpassword-error/24935/5 "2019-12-20T22:33:55Z")

</div>

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