<?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 Re: Error when attempting to get an access token using refresh token in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Error-when-attempting-to-get-an-access-token-using-refresh-token/m-p/622345#M28750</link>
    <description>&lt;P&gt;Hi &lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1573416"&gt;@GIS_questions&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Take a look on &lt;A href="https://github.com/dropbox/dropbox-sdk-js/tree/main/examples/javascript" target="_blank"&gt;https://github.com/dropbox/dropbox-sdk-js/tree/main/examples/javascript&lt;/A&gt; &lt;img class="lia-deferred-image lia-image-emoji" src="https://www.dropboxforum.com/html/@41457EF40051AFF130FDBFE21B496926/emoticons/1f609.png" alt=":winking_face:" title=":winking_face:" /&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
    <pubDate>Tue, 13 Sep 2022 21:35:10 GMT</pubDate>
    <dc:creator>Здравко</dc:creator>
    <dc:date>2022-09-13T21:35:10Z</dc:date>
    <item>
      <title>Error when attempting to get an access token using refresh token</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Error-when-attempting-to-get-an-access-token-using-refresh-token/m-p/622066#M28744</link>
      <description>&lt;P&gt;I keep encountering the same error when I attempt to use my refresh token, client id and client secret to get a new access token in my javascript code:&lt;/P&gt;
&lt;P&gt;" Error in call to API function "files/upload": Invalid authorization value in HTTP header "Authorization": "Bearer". Expecting "Bearer &amp;lt;oauth2-access-token&amp;gt;".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've tried many times but I keep coming back to the same error, whether I use a fetch method, post, or get. I know my information is correct, because a curl request gives me a working access token, but I seem to be messing something up. I've read through all the resources I can find, but I think I must be making a mistake when applying this code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help would be greatly appreciated, as I am very new to javascript and the removal of long-lived access tokens has thrown me for a loop!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(The images below are all different attempts, each of which failed with the same error.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="attempt1_Dropbox.png" style="width: 800px;"&gt;&lt;img src="https://www.dropboxforum.com/t5/image/serverpage/image-id/31592iEFDC42B675756939/image-size/large?v=v2&amp;amp;px=999" role="button" title="attempt1_Dropbox.png" alt="attempt1_Dropbox.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="attempt2_dropbox.png" style="width: 800px;"&gt;&lt;img src="https://www.dropboxforum.com/t5/image/serverpage/image-id/31593i9F88CAD1C9576AF1/image-size/large?v=v2&amp;amp;px=999" role="button" title="attempt2_dropbox.png" alt="attempt2_dropbox.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="attempt3_dropbox.png" style="width: 800px;"&gt;&lt;img src="https://www.dropboxforum.com/t5/image/serverpage/image-id/31595iE1C5E360FF24BB39/image-size/large?v=v2&amp;amp;px=999" role="button" title="attempt3_dropbox.png" alt="attempt3_dropbox.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="attempt4_dropbox.png" style="width: 554px;"&gt;&lt;img src="https://www.dropboxforum.com/t5/image/serverpage/image-id/31594i07D1B1D15B7EF8C0/image-size/large?v=v2&amp;amp;px=999" role="button" title="attempt4_dropbox.png" alt="attempt4_dropbox.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Sep 2022 05:10:16 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Error-when-attempting-to-get-an-access-token-using-refresh-token/m-p/622066#M28744</guid>
      <dc:creator>GIS_questions</dc:creator>
      <dc:date>2022-09-13T05:10:16Z</dc:date>
    </item>
    <item>
      <title>Re: Error when attempting to get an access token using refresh token</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Error-when-attempting-to-get-an-access-token-using-refresh-token/m-p/622276#M28747</link>
      <description>&lt;P&gt;It looks like you're attempting to use a refresh token as a "Bearer" token in a few places in this case (where you set the "Authorization" header to "Bearer" + refreshToken). Refresh tokens themselves are not access tokens and cannot be used as Bearer tokens though, so please update your code to remove that. Refresh tokens should only be used as the "refresh_token" parameter value (as you do have) when calling &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#oauth2-token" target="_blank"&gt;/oauth2/token&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, I see in one line that you have a reference to "api.dropboxapi.com/oauth2/token_access_type=offline". That is not correct, and appears to be a combination of "api.dropboxapi.com/oauth2/token", which is the Dropbox OAuth 2 token endpoint, and "token_access_type=offline" which is only a parameter/option on &lt;A href="http://www.dropbox.com/oauth2/authorize" target="_blank"&gt;www.dropbox.com/oauth2/authorize&lt;/A&gt;. You can find more information in the &lt;A href="https://developers.dropbox.com/oauth-guide" target="_blank"&gt;OAuth Guide&lt;/A&gt; and &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#authorization" target="_blank"&gt;authorization documentation&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Get-refresh-token-from-access-token/m-p/596755/highlight/true#M27728" target="_blank"&gt;This comment with a basic example of the whole procedure&lt;/A&gt; may be a useful reference.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Sep 2022 15:05:49 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Error-when-attempting-to-get-an-access-token-using-refresh-token/m-p/622276#M28747</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2022-09-13T15:05:49Z</dc:date>
    </item>
    <item>
      <title>Re: Error when attempting to get an access token using refresh token</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Error-when-attempting-to-get-an-access-token-using-refresh-token/m-p/622339#M28748</link>
      <description>&lt;P&gt;Hi Greg,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much for your reply!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you have any basic examples of doing this through javascript? I've been able to get the refresh token using curl, but I haven't had the same luck with my code. I've looked at the documentation on the OAuth guide and authorization documentation but I can't get the Javascript to function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 13 Sep 2022 20:49:22 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Error-when-attempting-to-get-an-access-token-using-refresh-token/m-p/622339#M28748</guid>
      <dc:creator>GIS_questions</dc:creator>
      <dc:date>2022-09-13T20:49:22Z</dc:date>
    </item>
    <item>
      <title>Re: Error when attempting to get an access token using refresh token</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Error-when-attempting-to-get-an-access-token-using-refresh-token/m-p/622345#M28750</link>
      <description>&lt;P&gt;Hi &lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1573416"&gt;@GIS_questions&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Take a look on &lt;A href="https://github.com/dropbox/dropbox-sdk-js/tree/main/examples/javascript" target="_blank"&gt;https://github.com/dropbox/dropbox-sdk-js/tree/main/examples/javascript&lt;/A&gt; &lt;img class="lia-deferred-image lia-image-emoji" src="https://www.dropboxforum.com/html/@41457EF40051AFF130FDBFE21B496926/emoticons/1f609.png" alt=":winking_face:" title=":winking_face:" /&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Sep 2022 21:35:10 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Error-when-attempting-to-get-an-access-token-using-refresh-token/m-p/622345#M28750</guid>
      <dc:creator>Здравко</dc:creator>
      <dc:date>2022-09-13T21:35:10Z</dc:date>
    </item>
    <item>
      <title>Re: Error when attempting to get an access token using refresh token</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Error-when-attempting-to-get-an-access-token-using-refresh-token/m-p/622506#M28756</link>
      <description>&lt;P&gt;&lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1573416"&gt;@GIS_questions&lt;/a&gt; As Здравко referred to, I recommend using &lt;A href="https://github.com/dropbox/dropbox-sdk-js" target="_blank" rel="noopener"&gt;the official Dropbox JavaScript SDK&lt;/A&gt; if possible, as it will do much of the work for you. Alternatively, it may also just serve as a good example even if you can't use it.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Sep 2022 20:46:43 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Error-when-attempting-to-get-an-access-token-using-refresh-token/m-p/622506#M28756</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2022-09-14T20:46:43Z</dc:date>
    </item>
    <item>
      <title>Re: Error when attempting to get an access token using refresh token</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Error-when-attempting-to-get-an-access-token-using-refresh-token/m-p/623734#M28813</link>
      <description>&lt;P&gt;Hi &lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/10"&gt;@Greg-DB&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would you mind taking a look at this code and telling me where I'm going wrong? Currently I'm getting a 400 error regarding the bearer. I am using the access code for the bearer, though I don't know if it has to be the access token? The problem there being that I have to use this code to get the temporary access token, so I don't know how to request the access token without a preexisting access token, if that makes any sense? I'm using the url: &lt;A href="https://api.dropbox.com/oauth2/token" target="_blank"&gt;https://api.dropbox.com/oauth2/token&lt;/A&gt;. I've also tried this without the Authorization request header, and with a grant_type of client_credentials.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="GIS_questions_0-1663681370554.png" style="width: 400px;"&gt;&lt;img src="https://www.dropboxforum.com/t5/image/serverpage/image-id/31779i67AD8A66D04759A6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="GIS_questions_0-1663681370554.png" alt="GIS_questions_0-1663681370554.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much for your help!&lt;/P&gt;</description>
      <pubDate>Tue, 20 Sep 2022 13:55:12 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Error-when-attempting-to-get-an-access-token-using-refresh-token/m-p/623734#M28813</guid>
      <dc:creator>GIS_questions</dc:creator>
      <dc:date>2022-09-20T13:55:12Z</dc:date>
    </item>
    <item>
      <title>Re: Error when attempting to get an access token using refresh token</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Error-when-attempting-to-get-an-access-token-using-refresh-token/m-p/623755#M28818</link>
      <description>&lt;P&gt;Whenever you get an error like this 400 error response, be sure to print out the response body as it will generally contain a more useful error message. What does it contain in this case?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looking at your code though, I see you're attempting the step where you call /oauth2/token with the existing refresh token to get a new short-lived access token. That corresponds to the "refresh token request" example in &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#oauth2-token" target="_blank"&gt;the documentation for /oauth2/token&lt;/A&gt;. There are a few things that look wrong in your code as compared to that:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;you should not be supplying a Bearer token/code; this step does not require or accept an access token or authorization code&lt;/LI&gt;
&lt;LI&gt;you should not be setting the Content-Type to application/json or JSON-encoding your parameters; this OAuth endpoint expects the parameters as application/x-www-form-urlencoded POST parameters&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Tue, 20 Sep 2022 14:58:27 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Error-when-attempting-to-get-an-access-token-using-refresh-token/m-p/623755#M28818</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2022-09-20T14:58:27Z</dc:date>
    </item>
  </channel>
</rss>

