<?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: Dropbox SDK Integration: Access Token Challenges in Discuss Dropbox Developer &amp; API</title>
    <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Dropbox-SDK-Integration-Access-Token-Challenges/m-p/736778#M3808</link>
    <description>&lt;P&gt;Would be enough something like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;this.fileClient = new Dropbox({
  refreshToken: process.env.DROPBOX_REFRESH_TOKEN,
  clientId: process.env.DROPBOX_CLIENT_ID,
  clientSecret: process.env.DROPBOX_CLIENT_SECRET,
  selectUser: process.env.DROPBOX_USER,
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To avoid meaningless refresh (usually need no more than once for 4 hours) in frequent client object construction, sharing a DropboxAuth object might be useful. Something like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;this.auth = new DropboxAuth({
  refreshToken: process.env.DROPBOX_REFRESH_TOKEN,
  clientId: process.env.DROPBOX_CLIENT_ID,
  clientSecret: process.env.DROPBOX_CLIENT_SECRET,
});

...

this.fileClient = new Dropbox({
  auth: this.auth,
  selectUser: process.env.DROPBOX_USER,
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Otherwise refresh will be executed on every client construction and if you just perform a single API call, the needed overall time will be doubled - decreased efficiency. To work the last, you need to keep 'auth' object global and shared throughout all your code (or saved with proper mutex protection), so the state won't start always from "zero". Of course this is optional - you decide whether improves your efficiency.&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;</description>
    <pubDate>Wed, 13 Dec 2023 13:00:01 GMT</pubDate>
    <dc:creator>Здравко</dc:creator>
    <dc:date>2023-12-13T13:00:01Z</dc:date>
    <item>
      <title>Dropbox SDK Integration: Access Token Challenges</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Dropbox-SDK-Integration-Access-Token-Challenges/m-p/736710#M3804</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;I'm currently working on developing a server-side application (using TypeScript) that integrates with Dropbox among other functionalities. I've created an application in the app console, granted it the necessary access, and subsequently generated an access token using the app console.&lt;/P&gt;&lt;P&gt;Within my application, I'm utilizing the Dropbox SDK and initializing it as follows:&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;this.fileClient = new Dropbox({
  accessToken: process.env.DROPBOX_ACCESS_TOKEN,
  selectUser: process.env.DROPBOX_USER,
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Initially, everything works smoothly until the access token expires, leading to an 'expired_access_token' error. I had the impression that the SDK would handle token refreshing automatically. Despite searching extensively, I haven't been able to find a solution.&lt;/P&gt;&lt;P&gt;By the way, the app console provides me with a short-lived token (starting with 'sl.').&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2023 08:21:33 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Dropbox-SDK-Integration-Access-Token-Challenges/m-p/736710#M3804</guid>
      <dc:creator>ojdev</dc:creator>
      <dc:date>2023-12-13T08:21:33Z</dc:date>
    </item>
    <item>
      <title>Re: Dropbox SDK Integration: Access Token Challenges</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Dropbox-SDK-Integration-Access-Token-Challenges/m-p/736718#M3806</link>
      <description>&lt;P&gt;Hi &lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1781153"&gt;@ojdev&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Yes, the SDK would refresh (regenerate in fact) access token if/when you provide refresh token together with app key and likely needed app secret - something that's missing in your code. Take a look &lt;A href="https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Issue-in-generating-access-token/m-p/592921/highlight/true#M27586" target="_blank" rel="noopener"&gt;here&lt;/A&gt; how you can get it by hands and use in your code later. You don't need the last step there - it's implemented in Dropbox SDK.&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2023 09:01:39 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Dropbox-SDK-Integration-Access-Token-Challenges/m-p/736718#M3806</guid>
      <dc:creator>Здравко</dc:creator>
      <dc:date>2023-12-13T09:01:39Z</dc:date>
    </item>
    <item>
      <title>Re: Dropbox SDK Integration: Access Token Challenges</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Dropbox-SDK-Integration-Access-Token-Challenges/m-p/736745#M3807</link>
      <description>&lt;P&gt;Thank you for your response!&lt;/P&gt;&lt;P&gt;Following the mentioned process, I acquired a refresh token.&lt;/P&gt;&lt;P&gt;I need clarification: will initializing my Dropbox SDK client like this suffice?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;this.fileClient = new Dropbox({
  accessToken: process.env.DROPBOX_ACCESS_TOKEN,
  refreshToken: process.env.DROPBOX_REFRESH_TOKEN,
  selectUser: process.env.DROPBOX_USER,
});&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;Or, do I need to initialize it differently, like this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;this.fileClient = new Dropbox({
  accessToken: process.env.DROPBOX_ACCESS_TOKEN,
  refreshToken: process.env.DROPBOX_REFRESH_TOKEN,
  clientId: process.env.DROPBOX_CLIENT_ID,
  clientSecret: process.env.DROPBOX_CLIENT_SECRET,
  selectUser: process.env.DROPBOX_USER,
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2023 10:24:25 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Dropbox-SDK-Integration-Access-Token-Challenges/m-p/736745#M3807</guid>
      <dc:creator>ojdev</dc:creator>
      <dc:date>2023-12-13T10:24:25Z</dc:date>
    </item>
    <item>
      <title>Re: Dropbox SDK Integration: Access Token Challenges</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Dropbox-SDK-Integration-Access-Token-Challenges/m-p/736778#M3808</link>
      <description>&lt;P&gt;Would be enough something like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;this.fileClient = new Dropbox({
  refreshToken: process.env.DROPBOX_REFRESH_TOKEN,
  clientId: process.env.DROPBOX_CLIENT_ID,
  clientSecret: process.env.DROPBOX_CLIENT_SECRET,
  selectUser: process.env.DROPBOX_USER,
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To avoid meaningless refresh (usually need no more than once for 4 hours) in frequent client object construction, sharing a DropboxAuth object might be useful. Something like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;this.auth = new DropboxAuth({
  refreshToken: process.env.DROPBOX_REFRESH_TOKEN,
  clientId: process.env.DROPBOX_CLIENT_ID,
  clientSecret: process.env.DROPBOX_CLIENT_SECRET,
});

...

this.fileClient = new Dropbox({
  auth: this.auth,
  selectUser: process.env.DROPBOX_USER,
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Otherwise refresh will be executed on every client construction and if you just perform a single API call, the needed overall time will be doubled - decreased efficiency. To work the last, you need to keep 'auth' object global and shared throughout all your code (or saved with proper mutex protection), so the state won't start always from "zero". Of course this is optional - you decide whether improves your efficiency.&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2023 13:00:01 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Dropbox-SDK-Integration-Access-Token-Challenges/m-p/736778#M3808</guid>
      <dc:creator>Здравко</dc:creator>
      <dc:date>2023-12-13T13:00:01Z</dc:date>
    </item>
    <item>
      <title>Re: Dropbox SDK Integration: Access Token Challenges</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Dropbox-SDK-Integration-Access-Token-Challenges/m-p/736869#M3810</link>
      <description>&lt;P&gt;Thank you! You're a real life saver.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2023 17:43:05 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Dropbox-SDK-Integration-Access-Token-Challenges/m-p/736869#M3810</guid>
      <dc:creator>ojdev</dc:creator>
      <dc:date>2023-12-13T17:43:05Z</dc:date>
    </item>
  </channel>
</rss>

