Need some help getting the AuthenticateByName call to work on my test server with 10.8.0.
Looks like there may be API changes coming in 10.8.0 version. I am using the API Docs built into the server - http://watch.tv/jellyfin/api-docs/swagger/index.html. As well as the API Docs located here - Jellyfin - ReDoc. I must not understand what has changed.
The below python script function call works with the current stable version but no longer works with the 10.8.0 version:
def get_auth_key(server_url, username, password, password_sha1):
#Get Auth Token for admin account
values = {'Username' : username, 'Password' : password_sha1, 'Pw' : password}
DATA = urllib.parse.urlencode(values)
DATA = DATA.encode('ascii')
headers = {'X-Emby-Authorization' : 'Emby UserId="'+ username +'", Client="media_cleaner", Device="media_cleaner", DeviceId="media_cleaner", Version="0.2", Token=""'}
req = request.Request(url=server_url +'/Users/AuthenticateByName', data=DATA,method='POST', headers=headers)
with request.urlopen(req) as response:
if response.getcode() == 200:
source = response.read()
data = json.loads(source)
#DEBUG
#jprint(data)
else:
print('An error occurred while attempting to retrieve data from the API.')
return(data['AccessToken'])
Above Variable Contents:
server_url = http://watch.tv/jellyfin
values = {'Username': 'Hieroglyph.Admin', 'Password': '8dd84bdbf504f52bdcccb08b1dd456d1fdf000c3', 'Pw': '76X9Vw6E36C2bNc5xkAj25MaRwtzRFKP'}
DATA = Username=Hieroglyph.Admin&Password=8dd84bdbf504f52bdcccb08b1dd456d1fdf000c3&Pw=76X9Vw6E36C2bNc5xkAj25MaRwtzRFKP
headers = {'X-Emby-Authorization': 'Emby UserId="Hieroglyph.Admin", Client="media_cleaner", Device="media_cleaner", DeviceId="media_cleaner", Version="0.2", Token=""'}
End up with a urllib.error.HTTPError: HTTP Error 415: Unsupported Media Type error:
Traceback (most recent call last):
File "./media_cleaner.py", line 678, in <module>
auth_key=get_auth_key(server_url, username, password, password_sha1)
File "./media_cleaner.py", line 254, in get_auth_key
with request.urlopen(req) as response:
File "/usr/local/lib/python3.8/urllib/request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "/usr/local/lib/python3.8/urllib/request.py", line 531, in open
response = meth(req, response)
File "/usr/local/lib/python3.8/urllib/request.py", line 640, in http_response
response = self.parent.error(
File "/usr/local/lib/python3.8/urllib/request.py", line 569, in error
return self._call_chain(*args)
File "/usr/local/lib/python3.8/urllib/request.py", line 502, in _call_chain
result = func(*args)
File "/usr/local/lib/python3.8/urllib/request.py", line 649, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 415: Unsupported Media Type
Am I supposed to specify applicaiton/json as the Media Type?
And if so, how do I do that?