No token provided angular spotify api
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
**Code is in Angular typescript
I got an access token using:
getToken() {
const headers = new HttpHeaders({
'Content-Type': 'application/x-www-form-urlencoded'
});
return this.http.post('https://accounts.spotify.com/api/token', 'grant_type=client_credentials&client_id=c9477994743c439ba8cbe8591b96275b&client_secret=d118aa20a1904049ac3cc905077944ff', { headers: headers });
}
I then tried to call an endpoint using:
getArtist() {
const headers = new HttpHeaders({
'Authorization': 'BQA1O6zV2ZmW0RVIEZFFtQPgGL5uLV_iji0nZkSwwwmmdAmKyRKjKNuQn_UjIgx7gUBzhcB30VhuZZ5XE29PwEKNjnHLcJj-chSk6BA7u-faFsnKH7c'
});
return this.http.post('https://api.spotify.com/v1/artists/4Z8W4fKeB5YxbusRsdQVPb', { headers: headers });
}
However, it keeps giving me the 401 error that I did not provide a token. I feel like my code is correct?
Labels:
- Labels:
-
angular
-
endpoint error
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page