Help Wizard

Step 1

NEXT STEP

getMyTopTracks not working

Solved!

getMyTopTracks not working

I have been trying to get my top tracks using this in Typescript:

async getDefault2(){
let tracks = await this.authService.getApi().getMyTopTracks({
time_range: "medium_term",
});
console.log(tracks)
}

The strange part is that the only method that is actually working is getMe() and I don't know why! I always get a 403 error!

Reply

Accepted Solutions
Marked as solution

You are missing the user-top-read Scope.

(I assume you have Authorization implemented.)

View solution in original post

6 Replies

Can you please post code of how you get an Access Token?

First the login:

window.location.href = `https://accounts.spotify.com/authorize?client_id=${client_id}&redirect_uri=${redirect_uri}&response_type=token&show_dialog=true`;

Then when I get redirected, I get the token like this:

const token = this.route.snapshot.fragment.split('&')
.find(fragment => fragment.includes('access_token'))
.split('=')[1];

this.spotifyApi.setAccessToken(token);

I am using 'spotify-web-api-js' library.

Marked as solution

You are missing the user-top-read Scope.

(I assume you have Authorization implemented.)

Thanks, that just worked fine!

i already added that scope but still not working 

@oozkanneray are you using an Authorization method other than Client Credentials? Because with that method, it won't work.

Suggested posts