brim-borium / spotify_sdk

Flutter Package to connect the spotify sdk
https://pub.dev/packages/spotify_sdk
Apache License 2.0
153 stars 82 forks source link

Identify Spotify user #170

Closed volgin closed 2 years ago

volgin commented 2 years ago

I need to store information about a user after connecting to Spotify. Oauth providers (Google. Facebook, etc.) supply some form of unique user ID, which we can store in the database. It appears that Spotify only has user's email address as a form of identification. If that's the case, it will be great if you add getUserEmail() method when access token includes user_read_email scope.

fotiDim commented 2 years ago

@volgin which platform are you targeting?

volgin commented 2 years ago

Initially iOs and Android, but later may add web and/or WIndows/MacOs.

volgin commented 2 years ago

Actually, Spotify does have a user ID: https://developer.spotify.com/documentation/web-api/reference/#/operations/get-current-users-profile

This requires [user-read-private] scope. Either call works for my purposes as both IDs and emails are unique identifiers.

fotiDim commented 2 years ago

@volgin this plugin only supports iOS/Android/Web. Not sure how you plan to support desktop platforms. Regarding your request, I can only speak about iOS. There is a (long) way to get the user's email through the native iOS SDK but it is not supported in this plugin for reason's of consistency and simplicity. What I suggest instead is to add the scope and then use Spotify's web API to get the email address of the user. There is the Spotify package that can help you with this. It should be simple enough to do.

volgin commented 2 years ago

I need functionality that the spofity package does not support yet. Will it be a problem if I get an access token through your package, and then use it to obtain additional information through spotify package? Or it's better to simply make a direct call to the Spotify API endpoint using the access token from your package?

fotiDim commented 2 years ago

Yes that was exactly my suggestion. It's up to you to decide if you want to use the Spotify package. If it is for a single call I guess it does not make sense as it will bring a lot of dependencies.

But definitely double check how you plan to support desktop platforms.

fotiDim commented 2 years ago

@volgin can we close this? As suggested it is better to tackle this over the web api.

volgin commented 2 years ago

Yes, you can close it.