<?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 redirect_uri mismatch with unknown cause php in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/redirect-uri-mismatch-with-unknown-cause-php/m-p/400460#M21923</link>
    <description>&lt;P&gt;I was using my php curl to request a token from the api. I set up my parameter array correctly. However, I get this error in return :{"error_description": "redirect_uri mismatch", "error": "invalid_grant"}400&lt;/P&gt;
&lt;P&gt;This was my implementation:&lt;/P&gt;
&lt;PRE&gt;$dropbox_url = "https://api.dropboxapi.com/oauth2/token";
$timeout = 40;
$app_key = key;
$app_secret = secret;
try {
$d1curl = curl_init();
$http_headers = array(
	"Authorization: Basic " . base64_encode($app_key . ":" . $app_secret),
	"Content-Type: application/x-www-form-urlencoded"
	);
$parameters = array(
	'code' =&amp;gt; $code,
	'grant_type' =&amp;gt; 'authorization_code',
	'redirect_uri' =&amp;gt; url	
);
curl_setopt($d1curl, CURLOPT_URL, $dropbox_url);
curl_setopt($d1curl, CURLOPT_TIMEOUT, $timeout);
curl_setopt($d1curl, CURLOPT_HTTPHEADER, $http_headers);
curl_setopt($d1curl, CURLOPT_POST, true);
curl_setopt($d1curl, CURLOPT_POSTFIELDS, http_build_query($parameters));
curl_setopt($d1curl, CURLOPT_RETURNTRANSFER, true);
$_SESSION['code'] = $_GET['code'];
$_SESSION['token'] = curl_exec($d1curl);
$http_request = curl_getinfo($d1curl, CURLINFO_HTTP_CODE);
echo $_SESSION['token'];
echo $http_request;
curl_close($d1curl);
}
catch(Exception $e) {
	echo curl_error($d1curl);
	curl_close($d1curl);
}&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;I copied and pasted it right out of my api console to double check the url itself.&lt;/P&gt;</description>
    <pubDate>Wed, 04 Mar 2020 06:43:11 GMT</pubDate>
    <dc:creator>FSUInnovation</dc:creator>
    <dc:date>2020-03-04T06:43:11Z</dc:date>
    <item>
      <title>redirect_uri mismatch with unknown cause php</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/redirect-uri-mismatch-with-unknown-cause-php/m-p/400460#M21923</link>
      <description>&lt;P&gt;I was using my php curl to request a token from the api. I set up my parameter array correctly. However, I get this error in return :{"error_description": "redirect_uri mismatch", "error": "invalid_grant"}400&lt;/P&gt;
&lt;P&gt;This was my implementation:&lt;/P&gt;
&lt;PRE&gt;$dropbox_url = "https://api.dropboxapi.com/oauth2/token";
$timeout = 40;
$app_key = key;
$app_secret = secret;
try {
$d1curl = curl_init();
$http_headers = array(
	"Authorization: Basic " . base64_encode($app_key . ":" . $app_secret),
	"Content-Type: application/x-www-form-urlencoded"
	);
$parameters = array(
	'code' =&amp;gt; $code,
	'grant_type' =&amp;gt; 'authorization_code',
	'redirect_uri' =&amp;gt; url	
);
curl_setopt($d1curl, CURLOPT_URL, $dropbox_url);
curl_setopt($d1curl, CURLOPT_TIMEOUT, $timeout);
curl_setopt($d1curl, CURLOPT_HTTPHEADER, $http_headers);
curl_setopt($d1curl, CURLOPT_POST, true);
curl_setopt($d1curl, CURLOPT_POSTFIELDS, http_build_query($parameters));
curl_setopt($d1curl, CURLOPT_RETURNTRANSFER, true);
$_SESSION['code'] = $_GET['code'];
$_SESSION['token'] = curl_exec($d1curl);
$http_request = curl_getinfo($d1curl, CURLINFO_HTTP_CODE);
echo $_SESSION['token'];
echo $http_request;
curl_close($d1curl);
}
catch(Exception $e) {
	echo curl_error($d1curl);
	curl_close($d1curl);
}&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;I copied and pasted it right out of my api console to double check the url itself.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Mar 2020 06:43:11 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/redirect-uri-mismatch-with-unknown-cause-php/m-p/400460#M21923</guid>
      <dc:creator>FSUInnovation</dc:creator>
      <dc:date>2020-03-04T06:43:11Z</dc:date>
    </item>
    <item>
      <title>Re: redirect_uri mismatch with unknown cause php</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/redirect-uri-mismatch-with-unknown-cause-php/m-p/400488#M21925</link>
      <description>&lt;P&gt;Can you share the full /oauth2/authorize URL you used to get the authorization code you're exchanging, as well as the redirect URI you're sending with this&amp;nbsp;/oauth2/token call (your 'url' variable in the above code)?&lt;/P&gt;
&lt;P&gt;Those need to match exactly. Keep in mind that you might have multiple different redirect URIs registered for your app, but you should use whichever one you used in the&amp;nbsp;/oauth2/authorize URL, if any.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Mar 2020 00:47:36 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/redirect-uri-mismatch-with-unknown-cause-php/m-p/400488#M21925</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2020-03-04T00:47:36Z</dc:date>
    </item>
    <item>
      <title>Re: redirect_uri mismatch with unknown cause php</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/redirect-uri-mismatch-with-unknown-cause-php/m-p/400907#M21942</link>
      <description>&lt;P&gt;So Simply Take the redirect uri I used when I sent the user to the oauth path earlier and refactor my php page to use that page again? Will I be able to supply a parameter of some kind so that I can reuse that redirect uri without repeating the previous step in my auth process again?&lt;/P&gt;</description>
      <pubDate>Thu, 05 Mar 2020 17:47:03 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/redirect-uri-mismatch-with-unknown-cause-php/m-p/400907#M21942</guid>
      <dc:creator>FSUInnovation</dc:creator>
      <dc:date>2020-03-05T17:47:03Z</dc:date>
    </item>
    <item>
      <title>Re: redirect_uri mismatch with unknown cause php</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/redirect-uri-mismatch-with-unknown-cause-php/m-p/400909#M21943</link>
      <description>&lt;P&gt;Regarding your first question, yes, the "redirect_uri" value you specified on&amp;nbsp;&lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#oauth2-authorize" target="_self"&gt;/oauth2/authorize&lt;/A&gt; should be the same "redirect_uri" value you then send to &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#oauth2-token" target="_self"&gt;/oauth2/token&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;I'm not sure I understand your second question though. You can re-use your redirect URI for each authorization, but note that each particular authorization code you get back can only be used once. You should exchange each authorization code via /oauth2/token once. The&amp;nbsp;/oauth2/token endpoint will return an access token that you can store and re-use to make API calls for that user without further manual user intervention though.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Mar 2020 18:02:10 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/redirect-uri-mismatch-with-unknown-cause-php/m-p/400909#M21943</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2020-03-05T18:02:10Z</dc:date>
    </item>
  </channel>
</rss>

