Skip to content

Commit

Permalink
Fix key name, use expires_in (#1324)
Browse files Browse the repository at this point in the history
  • Loading branch information
amCap1712 committed Mar 8, 2021
1 parent d0b97c7 commit f6ad0b4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion listenbrainz/domain/spotify.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def refresh_user_token(spotify_user: Spotify):
refresh_token = response['refresh_token']
else:
refresh_token = spotify_user.refresh_token
expires_at = response['expires_at']
expires_at = int(time.time()) + response['expires_in']
db_spotify.update_token(spotify_user.user_id, access_token, refresh_token, expires_at)
return get_user(spotify_user.user_id)

Expand Down
4 changes: 2 additions & 2 deletions listenbrainz/domain/tests/test_spotify.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def test_refresh_user_token(self, mock_requests, mock_update_token, mock_get_use
mock_requests.post(spotify.OAUTH_TOKEN_URL, status_code=200, json={
'access_token': 'tokentoken',
'refresh_token': 'refreshtokentoken',
'expires_at': expires_at,
'expires_in': 3600,
'scope': '',
})
spotify.refresh_user_token(self.spotify_user)
Expand All @@ -59,7 +59,7 @@ def test_refresh_user_token_only_access(self, mock_requests, mock_update_token,
expires_at = int(time.time()) + 3600
mock_requests.post(spotify.OAUTH_TOKEN_URL, status_code=200, json={
'access_token': 'tokentoken',
'expires_at': expires_at,
'expires_in': 3600,
'scope': '',
})
spotify.refresh_user_token(self.spotify_user)
Expand Down

0 comments on commit f6ad0b4

Please sign in to comment.