Help Wizard

Step 1

NEXT STEP

Spotify API (My user data)

Spotify API (My user data)

Hello,

 

I'm developing a personal website/developer profile and I'd like to display some user data from my own profile. Specifically, I'd like to display my all-time most listened to tracks and artists.

 

Is there a way to display this information on my website and keep it up to date without asking a user to login?

 

Thanks!

Reply
9 Replies

No, you cannot retrieve user data without asking the user to login. That would be a massive privacy violation.

True but let me clarify, is there a way that I can programmatically log into my own account without redirecting to the authentication page. Then display top tracks and artists for all users to see

It's not a possibility to do it programmatically in the frontend since you also would need to expose your login credentials. You might be able to build a backend which can authorize and get you an access token, you could then get your user stats and create an API endpoint that your personal website could call with a fetch request. You can read more about authorization flows here: https://developer.spotify.com/documentation/general/guides/authorization-guide/

What's a Spotify Rock Star, and how do I become one?

Check album availability here

No. Read the authorization guide. You only need to login once so this should not be an issue.

Hey, were you able to get this done, I've been trying to do the same thing for weeks, all I see is having to tap into the user's account, but i wanna programmatically log into mine for any user that uses my app and pull data from my own account for them 

You have to make a server side script that refreshes the access token with the refresh token when it expires. When the refresh token expires, you will get a new one while refreshing. (If it isn't expired, you will not get a new one.)

but is it possible to get the access and refresh tokens without taking the user through login, I mean I know I could use the client_credentials and get an access && refreshToken with just my clientId and secret, but will that give me access to "user-scoped functions" like getting user's currentPlayingTrack, where that user is ME, my account, the account from which I go the clientId and secret

@CrossDeveloper, You have to log in once to get the Authorization Code Flow with the necessary scopes. If you do this, you will get the necessary tokens automatically, and store those onto your server.

Ohhhhh makes sense now🤓 so i can just do the login now and get the tokens then use them for any other requests the user makes, then if the refresh token should expire, I could still redo the auth server side and replace the old token and just like that, Thanks a lot, makes sense now

Suggested posts