问题
I have tried using sp.core.user.canonicalUsername and m.User in various variants, I even tried to get the username by traversing through the m.playlists.starredPlaylist. This is probably easy but I can't find it somewhere?
回答1:
This is from a Spotify employee:
"Personally-indentifiable information like username won't be available, ever."
Typically, they want you to use Facebook Auth for any social features.
Apparently Spotify will be releasing new documentation in a week or so, so keep an eye out and see if it sheds any light.
回答2:
It won't be available, but you can obtain an unique user id with sp.core.getAnonymousUserId()
回答3:
It appears that you can use
var sp = getSpotifyApi(1);
var models = sp.require('sp://import/scripts/api/models');
models.session.anonymousUserID
From the Api Reference:
anonymousUserID string Get an anonymous user ID, which is unique per-user, per-application.
来源:https://stackoverflow.com/questions/8696537/how-do-i-get-the-current-user-username-in-spotify-apps