<?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: Help with generating access tokens in Node.js in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Help-with-generating-access-tokens-in-Node-js/m-p/623399#M28786</link>
    <description>&lt;P&gt;I appreciate pointing it out. I have changed to the following after some searching,&amp;nbsp; and now works as intended&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;import * as https from "https";

const req = https.request("https://api.dropbox.com/oauth2/token",{
    method: "POST",
    headers:{
        "Authorization":`Basic ${Buffer.from(`${&amp;lt;APP_KEY&amp;gt;}:${&amp;lt;SECRET_KEY&amp;gt;}`).toString("base64")}`,
        "Content-Type":"application/x-www-form-urlencoded"
    }
}, (res) =&amp;gt; {
    res.on("data", function(rawdat){
        console.log(rawdat.toString());
    })
});
req.write(new URLSearchParams({
    grant_type:"refresh_token",
    refresh_token: &amp;lt;REFRESH_TOKEN&amp;gt;
}).toString());
req.end();&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;</description>
    <pubDate>Mon, 19 Sep 2022 13:35:42 GMT</pubDate>
    <dc:creator>AndyLei</dc:creator>
    <dc:date>2022-09-19T13:35:42Z</dc:date>
    <item>
      <title>Help with generating access tokens in Node.js</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Help-with-generating-access-tokens-in-Node-js/m-p/623305#M28778</link>
      <description>&lt;P&gt;I am new to using https in Node.js, and Dropbox API, and am not familiar with the syntax. I have had no success finding Javascript examples on how to get an access token from a refresh token, and am asking here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;below is my current syntax, and i get the error:&lt;/P&gt;
&lt;P&gt;{"error": "unsupported_grant_type", "error_description": "missing required field \"grant_type\""}&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="javascript"&gt;import * as https from "https";

const req = https.request("https://api.dropbox.com/oauth2/token",{
    method: "POST",
    headers:{
        "Authorization":`Basic ${Buffer.from(`${&amp;lt;APP_KEY&amp;gt;}:${&amp;lt;SECRET_KEY&amp;gt;}`).toString("base64")}`,
        "Content-Type":"application/x-www-form-urlencoded"
    }
}, (res) =&amp;gt; {
    res.on("data", function(rawdat){
        console.log(rawdat.toString());
    })
});
req.write(JSON.stringify({
    grant_type:"refresh_token",
    refresh_token: &amp;lt;REFRESH_TOKEN&amp;gt;
}));
req.end();&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;This was cobbled together using what I understood from downloading and uploading, which I have successfully done using short-lived access tokens generated from the dashboard. Now however, I require access to the by dropbox app folder with a regular supply of access tokens.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Sep 2022 23:54:47 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Help-with-generating-access-tokens-in-Node-js/m-p/623305#M28778</guid>
      <dc:creator>AndyLei</dc:creator>
      <dc:date>2022-09-19T23:54:47Z</dc:date>
    </item>
    <item>
      <title>Re: Help with generating access tokens in Node.js</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Help-with-generating-access-tokens-in-Node-js/m-p/623391#M28782</link>
      <description>&lt;P&gt;Hi &lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1575085"&gt;@AndyLei&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Do you understand that you mixed 'urlencoded' with 'JSON'? &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 gives direction.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Sep 2022 12:48:05 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Help-with-generating-access-tokens-in-Node-js/m-p/623391#M28782</guid>
      <dc:creator>Здравко</dc:creator>
      <dc:date>2022-09-19T12:48:05Z</dc:date>
    </item>
    <item>
      <title>Re: Help with generating access tokens in Node.js</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Help-with-generating-access-tokens-in-Node-js/m-p/623392#M28783</link>
      <description>&lt;P&gt;I recommend using &lt;A href="https://github.com/dropbox/dropbox-sdk-js" target="_blank"&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Otherwise, refer to &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#oauth2-token" target="_blank"&gt;the documentation for /oauth2/token&lt;/A&gt;. It contains examples of calling the endpoint for different scenarios that you can translate to your platform.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, the error you posted here is indicating that the call failed because it's missing the required parameter "grant_type". I see you're attempting to set that, but you're trying to do so as JSON; this endpoints takes these parameters as application/x-www-form-urlencoded POST parameters, not JSON.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Sep 2022 12:48:40 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Help-with-generating-access-tokens-in-Node-js/m-p/623392#M28783</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2022-09-19T12:48:40Z</dc:date>
    </item>
    <item>
      <title>Re: Help with generating access tokens in Node.js</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Help-with-generating-access-tokens-in-Node-js/m-p/623399#M28786</link>
      <description>&lt;P&gt;I appreciate pointing it out. I have changed to the following after some searching,&amp;nbsp; and now works as intended&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;import * as https from "https";

const req = https.request("https://api.dropbox.com/oauth2/token",{
    method: "POST",
    headers:{
        "Authorization":`Basic ${Buffer.from(`${&amp;lt;APP_KEY&amp;gt;}:${&amp;lt;SECRET_KEY&amp;gt;}`).toString("base64")}`,
        "Content-Type":"application/x-www-form-urlencoded"
    }
}, (res) =&amp;gt; {
    res.on("data", function(rawdat){
        console.log(rawdat.toString());
    })
});
req.write(new URLSearchParams({
    grant_type:"refresh_token",
    refresh_token: &amp;lt;REFRESH_TOKEN&amp;gt;
}).toString());
req.end();&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;</description>
      <pubDate>Mon, 19 Sep 2022 13:35:42 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Help-with-generating-access-tokens-in-Node-js/m-p/623399#M28786</guid>
      <dc:creator>AndyLei</dc:creator>
      <dc:date>2022-09-19T13:35:42Z</dc:date>
    </item>
  </channel>
</rss>

