Open nequam opened 1 month ago
I just corrected the part where it gets a token, not where it was complaining continually that I need to add the user back again. I can't test that until I rebuild the docker container and push that to the machines that run things.
It was fun tracking it down and I learned a bit about python.
The change fixed it, it now works perfectly. :)
This is the change that I made to /content/services/trakt.py
Starting around line 159, replaced the post and the oauth functions.
def post(url, data, auth=False):
try:
if auth:
headers = {
'Content-type': "application/json"
}
else:
headers={
'Content-type': "application/json", "trakt-api-key": client_id, "trakt-api-version": "2",
"Authorization": "Bearer " + current_user[1]}
response = session.post(url, headers=headers, data=data)
logerror(response)
response = json.loads(response.content, object_hook=lambda d: SimpleNamespace(**d))
time.sleep(1.1)
except:
response = None
return response
def oauth(code=""):
if code == "":
response = post(url='https://api.trakt.tv/oauth/device/code', data=json.dumps({'client_id': client_id}), auth=True)
if not response is None:
return response.device_code, response.user_code
else:
print("trakt.tv could not be reached right now! Please try again later. The script will most likely exit after this message.")
time.sleep(5)
else:
response = None
while response is None:
response = post(url='https://api.trakt.tv/oauth/device/token', data=json.dumps(
{'code': code, 'client_id': client_id, 'client_secret': client_secret}),auth=True)
time.sleep(1)
return response.access_token
I had a problem with the oauth for trakt. I am NOT a python developer, mostly deal with C# and backend code.
I fixed part of it by changing the post function in the trakt.py in content/services by changing the headers when it's getting a code versus when it's just talking to trakt.
There is python library for trakt I'll check later if this is what the problem was.