<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Error with authorization using PHP Curl in Spotify for Developers</title>
    <link>https://community.spotify.com/t5/Spotify-for-Developers/Error-with-authorization-using-PHP-Curl/m-p/5320559#M3842</link>
    <description>&lt;P&gt;&lt;STRONG&gt;Plan&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Free&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Country&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Spain&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Device&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;PC&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Operating System&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Ubuntu 20.04&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My Question or Issue&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Im trying to make an application web for eductional purpose.&lt;/P&gt;&lt;P&gt;So far i tried this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="php"&gt;&amp;lt;?php

//$client_id = '&amp;lt;insert your spotify app client id&amp;gt;'; 
$client_id = 'da145e8c4b304dc3875a8e79a062c927'; 

//$client_secret = '&amp;lt;insert your spotify app client secret&amp;gt;'; 
$client_secret = '480dd953494c477c9a0c97c4fdcc459b'; 

$headers  = ['Authorization: Basic '.base64_encode($client_id.':'.$client_secret)];
//https://accounts.spotify.com/authorize/?client_id=CLIENT_ID&amp;amp;response_type=token&amp;amp;redirect_uri=http%3A%2F%2Flocalhost%3A8888%2Fcallback&amp;amp;scope=user-read-private%20playlist-modify-public&amp;amp;state=34fFs29kd09
$url= 'https://accounts.spotify.com/authorize';
$redirect_uri  = urlencode( 'http://localhost:8080/callback/loginspotify.php');
$statedado ='Hola';

$ch0 = curl_init();
 
curl_setopt( $ch0 , CURLOPT_URL, $url);
curl_setopt( $ch0, CURLOPT_FOLLOWLOCATION, true );
curl_setopt( $ch0, CURLOPT_HTTPGET, true );
curl_setopt( $ch0, CURLOPT_POSTFIELDS, 'state=' . $statedado );
curl_setopt( $ch0, CURLOPT_POSTFIELDS, 'response_type=code' );
curl_setopt( $ch0, CURLOPT_POSTFIELDS, 'scope=playlist-read-private%20playlist-modify-private' );
curl_setopt( $ch0, CURLOPT_POSTFIELDS, 'client_id=' . $client_id );
curl_setopt( $ch0, CURLOPT_POSTFIELDS, 'redirect_uri=' . $redirect_uri );
//curl_setopt( $ch0, CURLOPT_HTTPHEADER ,  $headers);

curl_exec($ch0);

$resultauth=curl_exec($ch0);

curl_close($ch0);

echo $resultauth;
 
$fullquery = 'https://accounts.spotify.com/authorize?response_type=code&amp;amp;state=' . $statedado. '&amp;amp;client_id='.$client_id.'&amp;amp;scope=playlist-read-private%20playlist-modify-private&amp;amp;redirect_uri='. $redirect_uri;

echo $fullquery;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When i execute my script:&lt;/P&gt;&lt;P&gt;&lt;A href="http://localhost:8080/provaspotify.php" target="_blank" rel="noopener"&gt;http://localhost:8080/provaspotify.php&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found the error attached in the image...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The strange thing is that if i got the fullquery and put it directly in the navitagtion bar of my browser... i got something&lt;/P&gt;&lt;P&gt;The fullquery:&amp;nbsp;&lt;SPAN&gt;&lt;A href="https://accounts.spotify.com/authorize?response_type=code&amp;amp;state=Hola&amp;amp;client_id=da145e8c4b304dc3875a8e79a062c927&amp;amp;scope=playlist-read-private%20playlist-modify-private&amp;amp;redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Fcallback%2Floginspotify.php" target="_blank" rel="noopener"&gt;https://accounts.spotify.com/authorize?response_type=code&amp;amp;state=Hola&amp;amp;client_id=da145e8c4b304dc3875a8e79a062c927&amp;amp;scope=playlist-read-private%20playlist-modify-private&amp;amp;redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Fcallback%2Floginspotify.php&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I got this response:&lt;/P&gt;&lt;P&gt;&lt;A href="http://localhost:8080/callback/loginspotify.php?code=AQCLeoPLgz-D9O5ECs0yPpE_vuUS2vgR_cMpb-p0lAjdbJsP2nVVS0CMCYhZYHHmdyFgPjZ-sUaAc1oS2FlUwgitvb5CYjH0wf816NTBWR6zKOIeiYwMSAkUnTrHueFfubeiD06WD43qHY1Dg7Kv4TqFfHiLvSmKcYDXb0vGNWbQXBwpGFBEAcD4u32FmdBbdEtzT6xTKcwljOPaVaRkBOfZXbi8PO5QksCXwckpTzwQ3JDuE0jrKvmy8EJxffMTo3HG&amp;amp;state=Hola" target="_blank" rel="noopener"&gt;http://localhost:8080/callback/loginspotify.php?code=AQCLeoPLgz-D9O5ECs0yPpE_vuUS2vgR_cMpb-p0lAjdbJsP2nVVS0CMCYhZYHHmdyFgPjZ-sUaAc1oS2FlUwgitvb5CYjH0wf816NTBWR6zKOIeiYwMSAkUnTrHueFfubeiD06WD43qHY1Dg7Kv4TqFfHiLvSmKcYDXb0vGNWbQXBwpGFBEAcD4u32FmdBbdEtzT6xTKcwljOPaVaRkBOfZXbi8PO5QksCXwckpTzwQ3JDuE0jrKvmy8EJxffMTo3HG&amp;amp;state=Hola&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So seems that somehow was authorized or something happened there.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be apreciated..this is the error im facing in the request&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;Error&amp;gt;
    &amp;lt;Code&amp;gt;AccessDenied&amp;lt;/Code&amp;gt;
    &amp;lt;Message&amp;gt;Access Denied&amp;lt;/Message&amp;gt;
    &amp;lt;RequestId&amp;gt;3Q87VNPZ813KR750&amp;lt;/RequestId&amp;gt;
    &amp;lt;HostId&amp;gt;Yy1nwW8u/aYLJyqjOwoZODuY+1g04nSA01avRuo5B+AfEQ1kNjeliEasOlyMduEwUAsNBdk2Vns=&amp;lt;/HostId&amp;gt;
&amp;lt;/Error&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Id like to access some personal data of the user, like playlist, but first of all the user have to give permissions...&lt;/P&gt;&lt;P&gt;By the way im the only user my account mail is &lt;A href="mailto:**bleep**," target="_blank" rel="noopener"&gt;**bleep**,&lt;/A&gt;&amp;nbsp;and im the only user authorised in my app. Also seems redirect uri is ok, because is the same as in the app.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Update 1:&lt;/P&gt;&lt;P&gt;Ive been making some tests. Seems a bug in spotify web api.&lt;/P&gt;&lt;P&gt;Also noticed that code in format:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="php"&gt;curl_setopt( $ch0, CURLOPT_URL, $url);
curl_setopt( $ch0, CURLOPT_FOLLOWLOCATION, true );
curl_setopt( $ch0, CURLOPT_HTTPGET, true );
curl_setopt( $ch0, CURLOPT_POSTFIELDS, 'response_type=code' );
curl_setopt( $ch0, CURLOPT_POSTFIELDS, 'client_id=' . $client_id );
curl_setopt( $ch0, CURLOPT_POSTFIELDS, 'scope=' . $scope);
curl_setopt( $ch0, CURLOPT_POSTFIELDS, 'redirect_uri=' . $redirect_uri );
curl_setopt( $ch0, CURLOPT_POSTFIELDS, 'state=' . $state );
curl_setopt( $ch0, CURLOPT_POSTFIELDS, 'show_dialog=' . 'true' );&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;doesnt like to spotify web api...But this one it seems to work&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="php"&gt;//////////Request User Authorization
$params = array('state' =&amp;gt; $state,'response_type' =&amp;gt; 'code', 'scope' =&amp;gt; $scope, 'client_id' =&amp;gt; $client_id, 'redirect_uri' =&amp;gt; $redirect_uri, 'show_dialog' =&amp;gt; 'true' );
$url = $endpoint . '?' . http_build_query($params);
curl_setopt($ch0, CURLOPT_URL, $url);
curl_setopt($ch0, CURLOPT_RETURNTRANSFER, true);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Seems a nonsense.&lt;/P&gt;&lt;P&gt;Seems important thing here is http_build_query instruction, for this reason i think it could be a bug, or it shold be documented...&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;curl&lt;/SPAN&gt;&lt;SPAN&gt;_setopt&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;$ch5&lt;/SPAN&gt;&lt;SPAN&gt;, CURLOPT_POSTFIELDS, &lt;/SPAN&gt;&lt;SPAN&gt;http_build_query&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;$params&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Update 2;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Although i receive a state and code, the script is not redirected to the redirect_uri...&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;i have to do a trick, its ugly, but works...i redirect to the page manually:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="php"&gt;$fullquery = 'https://accounts.spotify.com/authorize?response_type=code&amp;amp;state=' . $state. '&amp;amp;client_id='.$client_id.'&amp;amp;scope='. $scope.'&amp;amp;redirect_uri='. $redirect_uri;

echo $fullquery;
header('Location: '.$fullquery);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 29 Dec 2021 22:04:43 GMT</pubDate>
    <dc:creator>ejgutierrez</dc:creator>
    <dc:date>2021-12-29T22:04:43Z</dc:date>
    <item>
      <title>Error with authorization using PHP Curl</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Error-with-authorization-using-PHP-Curl/m-p/5320559#M3842</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Plan&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Free&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Country&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Spain&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Device&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;PC&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Operating System&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Ubuntu 20.04&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My Question or Issue&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Im trying to make an application web for eductional purpose.&lt;/P&gt;&lt;P&gt;So far i tried this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="php"&gt;&amp;lt;?php

//$client_id = '&amp;lt;insert your spotify app client id&amp;gt;'; 
$client_id = 'da145e8c4b304dc3875a8e79a062c927'; 

//$client_secret = '&amp;lt;insert your spotify app client secret&amp;gt;'; 
$client_secret = '480dd953494c477c9a0c97c4fdcc459b'; 

$headers  = ['Authorization: Basic '.base64_encode($client_id.':'.$client_secret)];
//https://accounts.spotify.com/authorize/?client_id=CLIENT_ID&amp;amp;response_type=token&amp;amp;redirect_uri=http%3A%2F%2Flocalhost%3A8888%2Fcallback&amp;amp;scope=user-read-private%20playlist-modify-public&amp;amp;state=34fFs29kd09
$url= 'https://accounts.spotify.com/authorize';
$redirect_uri  = urlencode( 'http://localhost:8080/callback/loginspotify.php');
$statedado ='Hola';

$ch0 = curl_init();
 
curl_setopt( $ch0 , CURLOPT_URL, $url);
curl_setopt( $ch0, CURLOPT_FOLLOWLOCATION, true );
curl_setopt( $ch0, CURLOPT_HTTPGET, true );
curl_setopt( $ch0, CURLOPT_POSTFIELDS, 'state=' . $statedado );
curl_setopt( $ch0, CURLOPT_POSTFIELDS, 'response_type=code' );
curl_setopt( $ch0, CURLOPT_POSTFIELDS, 'scope=playlist-read-private%20playlist-modify-private' );
curl_setopt( $ch0, CURLOPT_POSTFIELDS, 'client_id=' . $client_id );
curl_setopt( $ch0, CURLOPT_POSTFIELDS, 'redirect_uri=' . $redirect_uri );
//curl_setopt( $ch0, CURLOPT_HTTPHEADER ,  $headers);

curl_exec($ch0);

$resultauth=curl_exec($ch0);

curl_close($ch0);

echo $resultauth;
 
$fullquery = 'https://accounts.spotify.com/authorize?response_type=code&amp;amp;state=' . $statedado. '&amp;amp;client_id='.$client_id.'&amp;amp;scope=playlist-read-private%20playlist-modify-private&amp;amp;redirect_uri='. $redirect_uri;

echo $fullquery;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When i execute my script:&lt;/P&gt;&lt;P&gt;&lt;A href="http://localhost:8080/provaspotify.php" target="_blank" rel="noopener"&gt;http://localhost:8080/provaspotify.php&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found the error attached in the image...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The strange thing is that if i got the fullquery and put it directly in the navitagtion bar of my browser... i got something&lt;/P&gt;&lt;P&gt;The fullquery:&amp;nbsp;&lt;SPAN&gt;&lt;A href="https://accounts.spotify.com/authorize?response_type=code&amp;amp;state=Hola&amp;amp;client_id=da145e8c4b304dc3875a8e79a062c927&amp;amp;scope=playlist-read-private%20playlist-modify-private&amp;amp;redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Fcallback%2Floginspotify.php" target="_blank" rel="noopener"&gt;https://accounts.spotify.com/authorize?response_type=code&amp;amp;state=Hola&amp;amp;client_id=da145e8c4b304dc3875a8e79a062c927&amp;amp;scope=playlist-read-private%20playlist-modify-private&amp;amp;redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Fcallback%2Floginspotify.php&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I got this response:&lt;/P&gt;&lt;P&gt;&lt;A href="http://localhost:8080/callback/loginspotify.php?code=AQCLeoPLgz-D9O5ECs0yPpE_vuUS2vgR_cMpb-p0lAjdbJsP2nVVS0CMCYhZYHHmdyFgPjZ-sUaAc1oS2FlUwgitvb5CYjH0wf816NTBWR6zKOIeiYwMSAkUnTrHueFfubeiD06WD43qHY1Dg7Kv4TqFfHiLvSmKcYDXb0vGNWbQXBwpGFBEAcD4u32FmdBbdEtzT6xTKcwljOPaVaRkBOfZXbi8PO5QksCXwckpTzwQ3JDuE0jrKvmy8EJxffMTo3HG&amp;amp;state=Hola" target="_blank" rel="noopener"&gt;http://localhost:8080/callback/loginspotify.php?code=AQCLeoPLgz-D9O5ECs0yPpE_vuUS2vgR_cMpb-p0lAjdbJsP2nVVS0CMCYhZYHHmdyFgPjZ-sUaAc1oS2FlUwgitvb5CYjH0wf816NTBWR6zKOIeiYwMSAkUnTrHueFfubeiD06WD43qHY1Dg7Kv4TqFfHiLvSmKcYDXb0vGNWbQXBwpGFBEAcD4u32FmdBbdEtzT6xTKcwljOPaVaRkBOfZXbi8PO5QksCXwckpTzwQ3JDuE0jrKvmy8EJxffMTo3HG&amp;amp;state=Hola&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So seems that somehow was authorized or something happened there.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be apreciated..this is the error im facing in the request&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;Error&amp;gt;
    &amp;lt;Code&amp;gt;AccessDenied&amp;lt;/Code&amp;gt;
    &amp;lt;Message&amp;gt;Access Denied&amp;lt;/Message&amp;gt;
    &amp;lt;RequestId&amp;gt;3Q87VNPZ813KR750&amp;lt;/RequestId&amp;gt;
    &amp;lt;HostId&amp;gt;Yy1nwW8u/aYLJyqjOwoZODuY+1g04nSA01avRuo5B+AfEQ1kNjeliEasOlyMduEwUAsNBdk2Vns=&amp;lt;/HostId&amp;gt;
&amp;lt;/Error&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Id like to access some personal data of the user, like playlist, but first of all the user have to give permissions...&lt;/P&gt;&lt;P&gt;By the way im the only user my account mail is &lt;A href="mailto:**bleep**," target="_blank" rel="noopener"&gt;**bleep**,&lt;/A&gt;&amp;nbsp;and im the only user authorised in my app. Also seems redirect uri is ok, because is the same as in the app.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Update 1:&lt;/P&gt;&lt;P&gt;Ive been making some tests. Seems a bug in spotify web api.&lt;/P&gt;&lt;P&gt;Also noticed that code in format:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="php"&gt;curl_setopt( $ch0, CURLOPT_URL, $url);
curl_setopt( $ch0, CURLOPT_FOLLOWLOCATION, true );
curl_setopt( $ch0, CURLOPT_HTTPGET, true );
curl_setopt( $ch0, CURLOPT_POSTFIELDS, 'response_type=code' );
curl_setopt( $ch0, CURLOPT_POSTFIELDS, 'client_id=' . $client_id );
curl_setopt( $ch0, CURLOPT_POSTFIELDS, 'scope=' . $scope);
curl_setopt( $ch0, CURLOPT_POSTFIELDS, 'redirect_uri=' . $redirect_uri );
curl_setopt( $ch0, CURLOPT_POSTFIELDS, 'state=' . $state );
curl_setopt( $ch0, CURLOPT_POSTFIELDS, 'show_dialog=' . 'true' );&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;doesnt like to spotify web api...But this one it seems to work&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="php"&gt;//////////Request User Authorization
$params = array('state' =&amp;gt; $state,'response_type' =&amp;gt; 'code', 'scope' =&amp;gt; $scope, 'client_id' =&amp;gt; $client_id, 'redirect_uri' =&amp;gt; $redirect_uri, 'show_dialog' =&amp;gt; 'true' );
$url = $endpoint . '?' . http_build_query($params);
curl_setopt($ch0, CURLOPT_URL, $url);
curl_setopt($ch0, CURLOPT_RETURNTRANSFER, true);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Seems a nonsense.&lt;/P&gt;&lt;P&gt;Seems important thing here is http_build_query instruction, for this reason i think it could be a bug, or it shold be documented...&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;curl&lt;/SPAN&gt;&lt;SPAN&gt;_setopt&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;$ch5&lt;/SPAN&gt;&lt;SPAN&gt;, CURLOPT_POSTFIELDS, &lt;/SPAN&gt;&lt;SPAN&gt;http_build_query&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;$params&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Update 2;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Although i receive a state and code, the script is not redirected to the redirect_uri...&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;i have to do a trick, its ugly, but works...i redirect to the page manually:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="php"&gt;$fullquery = 'https://accounts.spotify.com/authorize?response_type=code&amp;amp;state=' . $state. '&amp;amp;client_id='.$client_id.'&amp;amp;scope='. $scope.'&amp;amp;redirect_uri='. $redirect_uri;

echo $fullquery;
header('Location: '.$fullquery);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Dec 2021 22:04:43 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Error-with-authorization-using-PHP-Curl/m-p/5320559#M3842</guid>
      <dc:creator>ejgutierrez</dc:creator>
      <dc:date>2021-12-29T22:04:43Z</dc:date>
    </item>
  </channel>
</rss>

