Christian Landgren
Christian Landgren

Reputation: 13763

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

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?

Upvotes: 1

Views: 2113

Answers (3)

user466784
user466784

Reputation:

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.

Upvotes: 1

Juan Riaza
Juan Riaza

Reputation: 1648

It won't be available, but you can obtain an unique user id with sp.core.getAnonymousUserId()

Upvotes: 1

Peter Watts
Peter Watts

Reputation: 710

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.

Upvotes: 3

Related Questions