1
votes

I am writing an app using spotify web api for personal use. It is a node.js application. I call the accounts.spotify.com/authorize endpoint and get redirected to the spotify login, but I am unable to log in using either Facebook or spotify username/password.

When I try to log in via Facebook, I get this error: "App Not Setup: This app is still in development mode, and you don't have access to it. Switch to a registered test user or ask an app admin for permissions." When I try to log in with the spotify username/password, I get this error: "Oops! Something went wrong, please try again or check out our help area"

Here is the code. It doesn't do much at this point other than redirect to the spotify login. I redacted the client_id and redirect URL. The redirect URL is accessible if I enter it directly in the browser. I believe that since I am getting the spotify login page, I am in the right ballpark, but maybe missed something in the app setup or the code.

Can someone tell me how to get past this error? Thanks.

var request = require('request');
function SpotifyLogin(req,res)
{
    var options =
    {
        url: 'http://accounts.spotify.com/authorize/?client_id=<redacted>&response_type=code&redirect_uri=<redacted>&scope=user-read-private&state=34fFs29kd09&show_dialog=true',
        followAllRedirects: true,
        followRedirect: true
    };

    request(options, function(error, response, body)
    {
        res.send(body);
        console.log(body);
        console.log(response.toJSON());
    }).on('error', function(e) {
        res.setHeader('Content-Type', 'text/html');
        res.send("<html><body>"+ e.message +"</body></html>");
        console.log("Got error: " + e.message);
    });

}
1
Is this correct in the URL? <redacted> - SerCrAsH
No, I took out the real client_id and redirect_uri and replaced them with the text "redacted." - Larry Person
Could you please try the /authorize URL and authorize your application by simply opening it in a browser? If an error occur after you've logged in, an error description should be displayed in the Developer Console. (Check Network and/or Console.) - Michael Thelin
A common issue is that the Redirect URI used when authorizing hasn't been added to the application, so I'd double-check that. - Michael Thelin
When I enter the /authorize URL with all the parameters directly into the browser and walk through the manual steps in the browser, spotify DOES redirect to the specified URL. The app seems to be set up correctly on spotify. In the case that doesn't work, when the browser hits a URL on my server and I do a request to spotify, I think I am doing something wrong when I send the initial response from spotify back to the browser. Thanks for your help. I'm still trying to figure out why I am not able to make it work when I sent the request to spotify from my server. Any thoughts? - Larry Person

1 Answers

0
votes

Thanks to jooon who made a suggestion in a comment, if my server returns a page that simply redirects the browser to https:/accounts.spotify.com/authenticate with the proper parameters, the authentication flow works correctly, resulting in spotify calling my callback URL.

Here it is with the spotify URL hardcoded and my client_id and redirect_url concealed.

function SpotifyLogin(req, res)
{
    res.writeHead(302, {
        'Location': encodeURI("https://accounts.spotify.com/authorize/?client_id=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&response_type=code&redirect_uri=http://xxxxxxx/callback/&scope=playlist-read-private playlist-read-collaborative playlist-modify-public playlist-modify-private streaming user-follow-modify user-follow-read user-library-read user-library-modify user-read-private user-read-birthdate user-read-email&state=34fFs29kd09&show_dialog=true")
    });
    res.send();
}