Skip to content

Commit

Permalink
narrowcasting: Hopefully prevent Spotify refresh loops when associati…
Browse files Browse the repository at this point in the history
…on expires
  • Loading branch information
Kurocon authored May 6, 2024
1 parent 4233a2d commit 5b0a879
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion amelie/narrowcasting/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,20 @@ def _spotify_refresh_token(association):
})

data = res.json()

if 'error' in data:
raise ValueError(data['error_description'])
elif res.status_code != 200:
raise ValueError(f"Status code: {res.status_code}")

try:
association.access_token = data['access_token']
association.save()
except KeyError:
except KeyError as e:
if 'error' in data:
raise ValueError(data['error_description'])
else:
raise e
return association

@cache_page(5)
Expand Down

0 comments on commit 5b0a879

Please sign in to comment.