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 <Access Token>
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.
ExamplesThe following example uses cURL
to retrieve information about a track using the Get a track endpoint:
_10
'https://api.spotify.com/v1/tracks/2TpxZ7JUBn3uw46aR7qd6V' \
_10
--header "Authorization: Bearer NgCXRK...MzYjw"
The following code implements the getProfile()
function which performs the API call to the Get Current User's Profile endpoint to retrieve the user profile related information:
_11
async function getProfile(accessToken) {
_11
let accessToken = localStorage.getItem('access_token');
_11
const response = await fetch('https://api.spotify.com/v1/me', {
_11
Authorization: 'Bearer ' + accessToken
_11
const data = await response.json();
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4