Trying Spotify API 1.x. My manifest
"Dependencies": {
"api": "1.20.1",
"views": "1.24.1"
}
Having problem getting the current session with the new spotify API. Session Docs
After a while I got the user information with this:
require(['$api/models','$api/models#User','$api/models#Session'], function(models) {
var user = models.User.fromURI('spotify:user:@');
user.load('username', 'name').done(function(u) {
userUid = u.identifier;
});
});
But the Session doesn't have the load method (getting throw error) and when looking at the models.Session I can't se any values??? :(
I changed on
manifest.json
API version to:Now I can get information from the session, for example my country:
I find the Spotify documentation a bit misleading regarding Sessions. There are a number of things I have found out by trial-and-error and Googling, rather than from the docs.
Like @Backer says, change the API version to 1.3.0 (or higher, when available). Please note you have to restart Spotify for this to take effect.
Then you can access the Session object like this (here, "session" must be lower case):
The User object will be part of this, but it won't be populated with properties unless you load them. Here is an example of retrieving a subset of properties from Session and User:
The entire Session object: