Created
November 25, 2019 22:17
-
-
Save badboybeyer/1b50ce5496685f22341139e4c5e0c53b to your computer and use it in GitHub Desktop.
simple code emulating tvdb_api.py logic to reproduce 401 failure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[[source]] | |
name = "pypi" | |
url = "https://pypi.org/simple" | |
verify_ssl = true | |
[dev-packages] | |
[packages] | |
requests = "*" | |
[requires] | |
python_version = "2.7" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"_meta": { | |
"hash": { | |
"sha256": "9838c8bf3aa442453b393e09e534ba7e1666aab4da1b9b408ecdf3ae58ab273c" | |
}, | |
"pipfile-spec": 6, | |
"requires": { | |
"python_version": "2.7" | |
}, | |
"sources": [ | |
{ | |
"name": "pypi", | |
"url": "https://pypi.org/simple", | |
"verify_ssl": true | |
} | |
] | |
}, | |
"default": { | |
"certifi": { | |
"hashes": [ | |
"sha256:e4f3620cfea4f83eedc95b24abd9cd56f3c4b146dd0177e83a21b4eb49e21e50", | |
"sha256:fd7c7c74727ddcf00e9acd26bba8da604ffec95bf1c2144e67aff7a8b50e6cef" | |
], | |
"version": "==2019.9.11" | |
}, | |
"chardet": { | |
"hashes": [ | |
"sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae", | |
"sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691" | |
], | |
"version": "==3.0.4" | |
}, | |
"idna": { | |
"hashes": [ | |
"sha256:c357b3f628cf53ae2c4c05627ecc484553142ca23264e593d327bcde5e9c3407", | |
"sha256:ea8b7f6188e6fa117537c3df7da9fc686d485087abf6ac197f9c46432f7e4a3c" | |
], | |
"version": "==2.8" | |
}, | |
"requests": { | |
"hashes": [ | |
"sha256:11e007a8a2aa0323f5a921e9e6a2d7e4e67d9877e85773fba9ba6419025cbeb4", | |
"sha256:9cf5292fcd0f598c671cfc1e0d7d1a7f13bb8085e9a590f48c010551dc6c4b31" | |
], | |
"index": "pypi", | |
"version": "==2.22.0" | |
}, | |
"urllib3": { | |
"hashes": [ | |
"sha256:a8a318824cc77d1fd4b2bec2ded92646630d7fe8619497b142c84a9e6f5a7293", | |
"sha256:f3c5fd51747d450d4dcf6f923c81f78f811aab8205fda64b0aba34a4e48b0745" | |
], | |
"version": "==1.25.7" | |
} | |
}, | |
"develop": {} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import requests | |
session = requests.session() | |
resp = session.post('https://api.thetvdb.com/login', | |
json={'apikey': '0629B785CE550C8D'}) | |
resp.raise_for_status() | |
token = resp.json()['token'] | |
session = requests.session() | |
session.params = {'name': 'mandalorian'} | |
session.headers = {'Accept-Language': 'en', | |
'Accept-Encoding': 'gzip,deflate', | |
'Accept': 'application/vnd.thetvdb.v3.0.0', | |
'User-Agent': 'python-requests/2.22.0', | |
'Connection': 'keep-alive', | |
'Authorization': u'Bearer %s' % token} | |
resp = session.get('https://api.thetvdb.com/search/series') | |
resp.raise_for_status() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment