node.js - Displaying permissions with spotify-web-api-node -



i'm using spotify-web-api-node authorize user can create , modify users playlist.
app works should. user can directed spotify accounts page,be authorized, , redirected app.
but when on spotify authorize page doesn't display permissions(scope) sought application. i'm guessing should image displayed here on spotify website. im not sure if case code isn't complete or there might issue spotify authorize page when using spotify-web-api-node.

edit

app.js

 var spotifywebapi = require('spotify-web-api-node');  var http = require('http'),  fs = require('fs'),  index = fs.readfilesync(__dirname + '/index.html');   // send index.html requests  var app = http.createserver(function(req, res) {  res.writehead(200, {'content-type': 'text/html'});  res.end(index);  });  var scopes = ['playlist-modify-public', 'playlist-modify-private'], redirecturi = 'http://localhost:3000', clientid = '', clientsecret = '', state = 'some-state-of-my-choice';  // setting credentials can done in wrapper's constructor. var spotifyapi = new spotifywebapi({ redirecturi : redirecturi, clientid : clientid, clientsecret : clientsecret });  // create authorization url var authorizeurl = spotifyapi.createauthorizeurl(scopes, state); console.log(authorizeurl);   // socket.io server listens our app var io = require('socket.io').listen(app); io.sockets.on('connection', function (socket){ io.sockets.emit('url',{value:authorizeurl});  //once code extracted client-side tokens socket.on('code', function(data){   var code = data.x;     // tokens   spotifyapi.authorizationcodegrant(code)     .then(function(data) {      console.log('the token expires in ' + data['expires_in']);     console.log('the access token ' + data['access_token']);     console.log('the refresh token ' + data['refresh_token']);     console.log(code);     }, function(err) {         console.log('something went wrong getting auth tokens !', err);       });      });    });app.listen(3000); 

html

<body>   <a><button>authorize</button></a>   <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>   <script src='//localhost:3000/socket.io/socket.io.js'></script>     <script>window.jquery || document.write('<script src="js/vendor/jquery-1.11.1.min.js"><\/script>')</script>     <script>    function getparameterbyname(name) {     name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");     var regex = new regexp("[\\?&]" + name + "=([^&#]*)"),     results = regex.exec(location.search);     return results === null ? "" : decodeuricomponent(results[1].replace(/\+/g, " "));     }        $( document ).ready(function() {         var socket = io.connect('//localhost:3000');         var code = getparameterbyname('code');             socket.emit('code', { x: code});             socket.on('url', function(data) {              $('a').attr('href',data.value);             });       });     </script>  </body> 

there's a test checks authorizeurl includes scopes. make sure scopes you're sending in in array. code should (obviously scopes, redirecturi, clientid, , state changed application's values)

var scopes = ['user-read-private', 'user-read-email'], redirecturi = 'https://example.com/callback', clientid = '5fe01282e44241328a84e7c5cc169165', state = 'some-state-of-my-choice';  var api = new spotifywebapi({     clientid : clientid,     redirecturi : redirecturi });  var authorizeurl = api.createauthorizeurl(scopes, state); console.log(authorizeurl); // "https://accounts.spotify.com/authorize?client_id=5fe01282e44241328a84e7c5cc169165&response_type=code&redirect_uri=https://example.com/callback&scope=user-read-private%20user-read-email&state=some-state-of-my-choice" 

hope helps! if not, please include code in question.


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -