How to get Oauth Token from Spotify
Currently I’m trying to learn how to add the liked youtube videos into a Spotify playlist using python and I’m learning from https://www.youtube.com/watch?v=7J_qcttfnJA&t=300s In 2:18 of the video, she mentions to add the userID and oauth token from spotify using spotify web API website https://developer.spotify.com/documentation/web-api/ However, I’m unable to find where is the OAUTH token. The programmer also uploaded an image of where she got her token from but I can’t seem to find it: https://github.com/TheComeUpCode/SpotifyGeneratePlaylist/blob/master/images/spotify_token.png
237k 19 19 gold badges 174 174 silver badges 251 251 bronze badges
asked Mar 12, 2020 at 18:24
77orudronald 77orudronald
71 1 1 gold badge 1 1 silver badge 3 3 bronze badges
2 Answers 2
Steps below to get the auth token:
- Navigate to the spotify developers documentation page: https://developer.spotify.com/
- On the top, Select on the console tab.
- From left hand side select on «tracks» and then «get a track», this should take you to page: https://developer.spotify.com/console/get-track/
- Now you should can see a «get token» button and «try it» button.
- Click on «Get Token» and you should get the OAuth Token.
answered Dec 6, 2021 at 2:10
71 1 1 silver badge 2 2 bronze badges
Go to https://developer.spotify.com/dashboard/ and create an spotify developer account. Then create an app and then you would get the client_id there.
Well, after that, the process to get the oauth token which is required for every call made to spoify api is quite tedious and it is user per basis. And user id is just the id of user who logged in to your app and let your app use spotify account details.
For oAuth token through your app UI — follow this —> https://www.youtube.com/watch?v=ZvGnvOShStI
THIS IS WHAT YOU NEED FOR TIME BEING —> If you want to authenticate yourself and get oAuth token go there —> https://developer.spotify.com/console/post-playlists/ and click get token.
answered Mar 12, 2020 at 18:29
2,122 2 2 gold badges 10 10 silver badges 26 26 bronze badges
thanks, I got that however I’m unable to get the Oauth Token!
Mar 12, 2020 at 18:31
- python
- spotify
-
The Overflow Blog
sponsored post
Related
Hot Network Questions
Subscribe to RSS
Question feed
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.11.15.1019
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.
How can I get an access token Spotify API?
I’ve been looking at the Spotify api for a few days now and example source code and I still can’t figure out how to get an access token to access a user’s playlist data. I’ve gotten to the point where I pull up the login window, the user logs in, and then I receive an authorization code. At this point, I tried doing things like:
window.open("https://accounts.spotify.com/api/token? grant_type=authorization_code&code="+code+"&redirect_uri=myurl&client_id=3137b15 2f1424defa2c6020ae5c6d444&client_secret=mysecret");
and
$.ajax( < url: "https://accounts.spotify.com/api/token?grant_type=authorization_code&code="+code+"&redirect_uri=myurl&client_secret=mysecret&client_id=myid", success: function(result)< alert("foo"); >> );
Spotify API. При запросе чтобы получить топ Артистов,Response 403. Как исправить?
По ссылке выше можно получить OAuth Token, и если делать запрос через него то всё получается, я не понимаю нужно ли делать запрос по новому токину или мой подойдёт ?
Access Token обновлен и если сделать запрос на несколько треков, то всё работает.
client_data = f':' client_data_bytes = client_data.encode('ascii') base64_bytes_client_data = base64.b64encode(client_data_bytes) base64_client_data = base64_bytes_client_data.decode('ascii') class RefreshToken: def __init__(self): self.refresh_token = refresh_token self.client_data = base64_client_data def refresh(self): query = 'https://accounts.spotify.com/api/token' response = requests.post(query, data=, headers=) response_object = response.json() return response_object['access_token'] obj = RefreshToken() refreshed_token = obj.refresh() def get_top_items(refreshed_token): type_item = 'artists' top_items_endpoint = f'https://api.spotify.com/v1/me/top/?' get_params = < 'time_range=': 'medium_term', 'limit=': '10', 'offset=': '5', >get_header = < 'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': 'Bearer ' + refreshed_token >res = requests.get(top_items_endpoint, params=get_params, headers=get_header) # top_objects = res.json() print(res)
- Вопрос задан более года назад
- 458 просмотров
Комментировать
Решения вопроса 1

soremix @SoreMix Куратор тега Python
403, как правило, говорит о том, что у пользователя нет прав для данного действия, неверный токен, токен истек. Как получали токен, какой скоуп передавали? Spotify явно хочет `user-top-read`, скорее всего не передали его
Access Token
The access token is a string which contains the credentials and permissions that can be used to access a given resource (e.g artists, albums or tracks) or user’s data (e.g your profile or your playlists).
To use the access token you must include the following header in your API calls:
| Header Parameter | Value |
|---|---|
| Authorization | Valid access token following the format: Bearer |
Note that the access token is valid for 1 hour (3600 seconds). After that time, the token expires and you need to request a new one.
Examples
The following example uses cURL to retrieve information about a track using the Get a track endpoint: