How do I get the current user username in Spotify Apps?

↘锁芯ラ 提交于 2019-12-11 08:52:19

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!