Here, we'll attempt to authenticate a user from Facebook.
/* Instantiate the global sp object; include models */
var sp = getSpotifyApi(1);
var auth = sp.require('sp://import/scripts/api/auth');
/* Set the permissions you want from the user. For more
* info, check out http://bit.ly/A4KCW3 */
var permissions = ['user_about_me'];
var app_id = '126891607432106';
$('#fb-login').click(function(){
auth.authenticateWithFacebook(app_id, permissions, {
onSuccess: function(accessToken, ttl) {
$('#fb-login').remove();
$('#status > p').append("<p>" + accessToken + "</p>");
$('#status > p').append("<p>The request took " + ttl + " ms.</p>");
},
onFailure: function(error) {
console.log("Authentication failed with error: " + error);
},
onComplete: function() { }
});
});
<img src="sp://coca/img/fb-login.png" id="fb-login" />
<div id="status"><p>If you've successfully authenticated with Facebook, this should be your access token:</p></div>
If you've successfully authenticated with Facebook, this should be your access token: