{"action":"created","issue":{"url":"https://api.github.com/repos/plamere/spotipy/issues/83","repository_url":"https://api.github.com/repos/plamere/spotipy","labels_url":"https://api.github.com/repos/plamere/spotipy/issues/83/labels{/name}","comments_url":"https://api.github.com/repos/plamere/spotipy/issues/83/comments","events_url":"https://api.github.com/repos/plamere/spotipy/issues/83/events","html_url":"https://github.com/plamere/spotipy/issues/83","id":138837006,"number":83,"title":"\"401 error: The access token expired\" when using SpotifyClientCredentials","user":{"login":"rinze","id":1757202,"avatar_url":"https://avatars1.githubusercontent.com/u/1757202?v=4","gravatar_id":"","url":"https://api.github.com/users/rinze","html_url":"https://github.com/rinze","followers_url":"https://api.github.com/users/rinze/followers","following_url":"https://api.github.com/users/rinze/following{/other_user}","gists_url":"https://api.github.com/users/rinze/gists{/gist_id}","starred_url":"https://api.github.com/users/rinze/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rinze/subscriptions","organizations_url":"https://api.github.com/users/rinze/orgs","repos_url":"https://api.github.com/users/rinze/repos","events_url":"https://api.github.com/users/rinze/events{/privacy}","received_events_url":"https://api.github.com/users/rinze/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-03-06T20:56:13Z","updated_at":"2018-02-12T08:57:05Z","closed_at":null,"author_association":"NONE","body":"I am creating my Spotipy object like this, after reading [this code snippet](https://github.com/plamere/spotipy/blob/master/examples/client_credentials_flow.py):\n\n```\nscc = SpotifyClientCredentials(client_id = SPOTIPY_CLIENT_ID,\n                                   client_secret = SPOTIPY_CLIENT_SECRET)\nsp = spotipy.Spotify(client_credentials_manager = scc)\n```\n\nHowever, after a number of queries, I obtain the following error:\n\n```\nhttp status:401                                                                 \nTraceback (most recent call last):                                              \n  File \"retriever2.py\", line 114, in <module>                                   \n    store_songs(terms, dbfile, total_number)                                    \n  File \"retriever2.py\", line 97, in store_songs                                 \n    songs = get_songs(sp, playlist)                                             \n  File \"retriever2.py\", line 36, in get_songs                                   \n    track_results = sp.next(track_results)                                      \n  File \"/home/chema/.local/lib/python2.7/site-packages/spotipy/client.py\", line 172, in next\n    return self._get(result['next'])                                            \n  File \"/home/chema/.local/lib/python2.7/site-packages/spotipy/client.py\", line 123, in _get\n    return self._internal_call('GET', url, payload, kwargs)                     \n  File \"/home/chema/.local/lib/python2.7/site-packages/spotipy/client.py\", line 104, in _internal_call\n    -1, '%s:\\n %s' % (r.url, r.json()['error']['message']))                     \nspotipy.client.SpotifyException: http status: 401, code:-1 - https://api.spotify.com/v1/users/1248788010/playlists/4wEVX1M28mBIpiHttM6PrP/tracks?offset=100&limit=100:\n The access token expired      \n```\n\nI was under the impression that `SpotifyClientCredentials` was used to update the access token accordingly. Right now, I have my queries inside a `try - except` block and I refresh it manually (I basically recreate the `sp` object every time I get an exception). Am I using this correctly or is there any other way?\n"},"comment":{"url":"https://api.github.com/repos/plamere/spotipy/issues/comments/364861889","html_url":"https://github.com/plamere/spotipy/issues/83#issuecomment-364861889","issue_url":"https://api.github.com/repos/plamere/spotipy/issues/83","id":364861889,"user":{"login":"ritiek","id":20314742,"avatar_url":"https://avatars1.githubusercontent.com/u/20314742?v=4","gravatar_id":"","url":"https://api.github.com/users/ritiek","html_url":"https://github.com/ritiek","followers_url":"https://api.github.com/users/ritiek/followers","following_url":"https://api.github.com/users/ritiek/following{/other_user}","gists_url":"https://api.github.com/users/ritiek/gists{/gist_id}","starred_url":"https://api.github.com/users/ritiek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ritiek/subscriptions","organizations_url":"https://api.github.com/users/ritiek/orgs","repos_url":"https://api.github.com/users/ritiek/repos","events_url":"https://api.github.com/users/ritiek/events{/privacy}","received_events_url":"https://api.github.com/users/ritiek/received_events","type":"User","site_admin":false},"created_at":"2018-02-12T08:57:05Z","updated_at":"2018-02-12T08:57:05Z","author_association":"NONE","body":"@Biggerandreas That should not be happening, I've been using something similar without problems. Do you mind sharing relevant code from your script here? (removing any credentials of course)"}}
{"actor":{"display_login":"ritiek"}}