2
votes

I have been working with the Spotify API. I want to perform some actions on playlists, these require a user to login. I want to execute the following url so as I can get an authorization bearer:

https://accounts.spotify.com/authorize/?client_id=CLIENT_ID&response_type=token&redirect_uri=http%3A%2F%2Flocalhost%3A8888%2Fcallback&scope=user-read-private%20playlist-modify-public&state=34fFs29kd09

When I execute this in a browser URL field, it works fine and will return an authorization token. I f i try to execute this from an index.php file however I run into problems.

<?php 
$curl = curl_init();
curl_setopt($curl,CURLOPT_URL,$url);
$output = curl_exec($curl);
curl_close($curl);
?>

When i run the file, the spotify login page will appear. However, after I enter my login details and hit enter nothing happens.

The console in the browser reports the following error:

POST http://localhost:8888/api/login 404 (Not Found) TypeError: Cannot create property 'error' on string '

<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /api/login was not found on this server.</p>
</body></html>

I have added a .htaccess to the folder as well as change the Directory AllowOverride to All in the httpd.conf file in my mamps server. There are multiple AllowOverrides and I am not 100% sure which one to change.

If it isn't obvious by now, I am copmletly lost when it comes to this so any help would be gratefully appreciated.

1

1 Answers

0
votes

Are your sure that page on localhost exists on that port? Is that page white listed on your dev-account on spotify?

You can also try this package from jwilsson, this way you don't have to fight whith the whole oauth process.