<?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 Access token is not being accepted from local server in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-token-is-not-being-accepted-from-local-server/m-p/255242#M14757</link>
    <description>&lt;P&gt;After successfully receiving an access token from the `oauth2/authorize` endpoint, I have attempted to submit the access token to `sharing/get_shared_link_metadata` along with the URL of a shared link. Several attempts have returned me with a 401 error. So I tried submitting an access token, which was generated from the app page, but with no success. However, when I copied/pasted my code to phpfiddle.com, the request returned successfully. So the issue seems to exist only in the request from my virtual server.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have no clue what issue could exist in a request from a virtual server, so any help would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 29 May 2019 09:16:55 GMT</pubDate>
    <dc:creator>njclonch</dc:creator>
    <dc:date>2019-05-29T09:16:55Z</dc:date>
    <item>
      <title>Access token is not being accepted from local server</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-token-is-not-being-accepted-from-local-server/m-p/255242#M14757</link>
      <description>&lt;P&gt;After successfully receiving an access token from the `oauth2/authorize` endpoint, I have attempted to submit the access token to `sharing/get_shared_link_metadata` along with the URL of a shared link. Several attempts have returned me with a 401 error. So I tried submitting an access token, which was generated from the app page, but with no success. However, when I copied/pasted my code to phpfiddle.com, the request returned successfully. So the issue seems to exist only in the request from my virtual server.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have no clue what issue could exist in a request from a virtual server, so any help would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 09:16:55 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-token-is-not-being-accepted-from-local-server/m-p/255242#M14757</guid>
      <dc:creator>njclonch</dc:creator>
      <dc:date>2019-05-29T09:16:55Z</dc:date>
    </item>
    <item>
      <title>Re: Access token is not being accepted from local server</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-token-is-not-being-accepted-from-local-server/m-p/255254#M14758</link>
      <description>Can you share your code and the full error response? Thanks in advance!</description>
      <pubDate>Mon, 04 Dec 2017 17:00:52 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-token-is-not-being-accepted-from-local-server/m-p/255254#M14758</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2017-12-04T17:00:52Z</dc:date>
    </item>
    <item>
      <title>Re: Access token is not being accepted from local server</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-token-is-not-being-accepted-from-local-server/m-p/255264#M14760</link>
      <description>&lt;P&gt;request:&lt;/P&gt;&lt;PRE&gt;public function getDropboxMetadata($url, $token)
{
	$ch = curl_init();

	curl_setopt($ch, CURLOPT_URL, 'https://api.dropboxapi.com/2/sharing/get_shared_link_metadata');
	curl_setopt($ch, CURLOPT_HTTPHEADER, [
		'Authorization: Bearer ' . $token,
		'Content-Type: application/json']);
	curl_setopt($ch, CURLOPT_POST, true);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(['url' =&amp;gt; $url]));

	$result = curl_exec($ch);

	curl_close($ch);

	return $result;
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;response:&lt;/P&gt;&lt;PRE&gt;error: {
	code: 401,
	errors: {
		0: {
			domain: "global",
			location: "Authorization",
			locationType: "header",
			message: "Invalid Credentials",
			reason: "authError"
		}
	},
	message: "Invalid Credentials"
}&lt;/PRE&gt;</description>
      <pubDate>Mon, 04 Dec 2017 18:41:02 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-token-is-not-being-accepted-from-local-server/m-p/255264#M14760</guid>
      <dc:creator>njclonch</dc:creator>
      <dc:date>2017-12-04T18:41:02Z</dc:date>
    </item>
    <item>
      <title>Re: Access token is not being accepted from local server</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-token-is-not-being-accepted-from-local-server/m-p/255274#M14763</link>
      <description>Thanks! I just tried this out, and it's working for me. &lt;BR /&gt;&lt;BR /&gt;Are you sure you're passing in a valid access token? I recommend printing out the $token just before you set the headers. It should be a 64 character string consisting of letters, numbers, and some symbols.</description>
      <pubDate>Mon, 04 Dec 2017 19:59:11 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-token-is-not-being-accepted-from-local-server/m-p/255274#M14763</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2017-12-04T19:59:11Z</dc:date>
    </item>
    <item>
      <title>Re: Access token is not being accepted from local server</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-token-is-not-being-accepted-from-local-server/m-p/255278#M14765</link>
      <description>&lt;P&gt;My issue is not with the code itself, because I've received a successful response when I've used it on phpfiddle.com. My issue is that I'm getting an error response on my local virtual server, and I have no clue why. I am hoping you may have some insight.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Dec 2017 20:31:35 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-token-is-not-being-accepted-from-local-server/m-p/255278#M14765</guid>
      <dc:creator>njclonch</dc:creator>
      <dc:date>2017-12-04T20:31:35Z</dc:date>
    </item>
    <item>
      <title>Re: Access token is not being accepted from local server</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-token-is-not-being-accepted-from-local-server/m-p/255279#M14766</link>
      <description>That indicates that something is wrong with the API request when made from your server. You'll need to inspect the request being made on your server. Since you're getting a 401, it seems likely that there is an issue with the access token. More generally, if you can print out the actual HTTP request that would likely be helpful.&lt;BR /&gt;&lt;BR /&gt;I'd be happy to take a look, but please don't post any output that contains an actual access token of course.</description>
      <pubDate>Mon, 04 Dec 2017 20:34:59 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-token-is-not-being-accepted-from-local-server/m-p/255279#M14766</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2017-12-04T20:34:59Z</dc:date>
    </item>
    <item>
      <title>Re: Access token is not being accepted from local server</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-token-is-not-being-accepted-from-local-server/m-p/255392#M14782</link>
      <description>&lt;P&gt;My process starts with a request for authorization:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;function requestDropboxAuth()
{
    $url = 'https://www.dropbox.com/oauth2/authorize';
    $data = [
	'client_id' =&amp;gt; '&amp;lt;client_id&amp;gt;',
	'redirect_uri' =&amp;gt; 'https://domain.com/validate/dropbox',
	'response_type' =&amp;gt; 'code'
    ];

    header('Location: ' . $url . '?' . http_build_query($data));
    die();
}&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This redirects me to the provided URI, with the following in the URL's parameters: '?code=&amp;lt;code&amp;gt;'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I then grab the &amp;lt;code&amp;gt; and submit a request via JavaScript&amp;amp;colon;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;function exchangeCodeForToken(code)
{
    if (code)
    {
	var xhr 	    = new XMLHttpRequest(),
	    oauth2Endpoint  = 'https://api.dropboxapi.com/oauth2/token',
	    clientId 	    = '&amp;lt;client_id&amp;gt;',
	    clientSecret    = '&amp;lt;client_secret&amp;gt;',
	    grantType 	    = 'authorization_code',
	    redirectUri     = location.origin + location.pathname;

	xhr.open('POST', oauth2Endpoint + '?code=' + code +
	    '&amp;amp;grant_type=' + grantType + '&amp;amp;redirect_uri=' + redirectUri +
	    '&amp;amp;client_id=' + clientId + '&amp;amp;client_secret=' + clientSecret);

	xhr.onreadystatechange = function(e)
	{
	    var response = JSON.parse(xhr.response);

	    if (xhr.readyState)
	    {
		if (xhr.status == 200 &amp;amp;&amp;amp; response.access_token)
		{
		    localStorage.setItem('dropbox-auth', JSON.stringify(response));
		}
		else
		{
		    console.log('There was an error processing the token, another response was returned, or the token was invalid.');
		}
	    }
	};

	    xhr.send(null);
	}
}&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The request headers from this are:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Accept-Encoding:gzip, deflate, br
Accept-Language:en-US,en;q=0.9
Cache-Control:no-cache
Connection:keep-alive
Cookie: [long string]
Host:domain.com
Pragma:no-cache
Referer:https://domain.com
Upgrade-Insecure-Requests:1
User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I save the access token, and then submit it with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;function getDropboxMetadata($url, $token)
{
    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, 'https://api.dropboxapi.com/2/sharing/get_shared_link_metadata');
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
	'Authorization: Bearer ' . $token,
	'Content-Type: application/json']);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(['url' =&amp;gt; $url]));

    $result = curl_exec($ch);

    curl_close($ch);

    return $result;
}&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The request headers from this are:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Accept:application/json, text/javascript, */*; q=0.01
Accept-Encoding:gzip, deflate, br
Accept-Language:en-US,en;q=0.9
Cache-Control:no-cache
Connection:keep-alive
Content-Length:310
Content-Type:application/x-www-form-urlencoded; charset=UTF-8
Cookie: [long string]
Host:domain.com
Origin:https://domain.com
Pragma:no-cache
Referer:https://domain.com
User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36
X-Requested-With:XMLHttpRequest&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Dec 2017 17:50:32 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-token-is-not-being-accepted-from-local-server/m-p/255392#M14782</guid>
      <dc:creator>njclonch</dc:creator>
      <dc:date>2017-12-05T17:50:32Z</dc:date>
    </item>
    <item>
      <title>Re: Access token is not being accepted from local server</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-token-is-not-being-accepted-from-local-server/m-p/255394#M14783</link>
      <description>Can you print out the request, or at least the token, to see what's getting sent by this code?</description>
      <pubDate>Tue, 05 Dec 2017 17:35:08 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-token-is-not-being-accepted-from-local-server/m-p/255394#M14783</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2017-12-05T17:35:08Z</dc:date>
    </item>
    <item>
      <title>Re: Access token is not being accepted from local server</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-token-is-not-being-accepted-from-local-server/m-p/255398#M14784</link>
      <description>&lt;P&gt;I added request headers to my previous post, which follow each respective request.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for your help. Let me know if you need more info.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Dec 2017 17:52:41 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-token-is-not-being-accepted-from-local-server/m-p/255398#M14784</guid>
      <dc:creator>njclonch</dc:creator>
      <dc:date>2017-12-05T17:52:41Z</dc:date>
    </item>
    <item>
      <title>Re: Access token is not being accepted from local server</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-token-is-not-being-accepted-from-local-server/m-p/255399#M14785</link>
      <description>Thanks. That appears to the be headers for a web request though (to your own app?) and not for the API call itself.</description>
      <pubDate>Tue, 05 Dec 2017 17:58:02 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-token-is-not-being-accepted-from-local-server/m-p/255399#M14785</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2017-12-05T17:58:02Z</dc:date>
    </item>
    <item>
      <title>Re: Access token is not being accepted from local server</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-token-is-not-being-accepted-from-local-server/m-p/255858#M14804</link>
      <description>&lt;P&gt;I think I'm doing everything correctly. I think the issue is just due to the last request originitating from a local server without authentic SSL. The access tokens I'm receiving seem to work, just not from my local server.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for your help.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2017 15:02:23 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-token-is-not-being-accepted-from-local-server/m-p/255858#M14804</guid>
      <dc:creator>njclonch</dc:creator>
      <dc:date>2017-12-08T15:02:23Z</dc:date>
    </item>
    <item>
      <title>Re: Access token is not being accepted from local server</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-token-is-not-being-accepted-from-local-server/m-p/255878#M14811</link>
      <description>I'm not sure I follow. Were you able to inspect the actual API requests like I suggested?</description>
      <pubDate>Fri, 08 Dec 2017 16:31:25 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-token-is-not-being-accepted-from-local-server/m-p/255878#M14811</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2017-12-08T16:31:25Z</dc:date>
    </item>
    <item>
      <title>Re: Access token is not being accepted from local server</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-token-is-not-being-accepted-from-local-server/m-p/255922#M14821</link>
      <description>&lt;P&gt;Sorry. I took the time to inspect the final request, which contains the access token in the request header. When I isolated the issue to the function, which contains the curl post/request, it came back with a successful response. So, to my embarrassment, there was actually just an issue somewhere else. I got really bogged down in this problem a couple days ago, and I think I just needed to step away from it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for the persistent help.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2017 19:02:35 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-token-is-not-being-accepted-from-local-server/m-p/255922#M14821</guid>
      <dc:creator>njclonch</dc:creator>
      <dc:date>2017-12-08T19:02:35Z</dc:date>
    </item>
  </channel>
</rss>

