<?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 Trouble Obtaining Refresh Token Alongside Access Token from Dropbox OAuth2 in Local Environment in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Trouble-Obtaining-Refresh-Token-Alongside-Access-Token-from/m-p/770551#M33690</link>
    <description>&lt;P&gt;I'm trying to integrate Dropbox into my web application using OAuth2. My code seems to be working correctly, but I'm only receiving the access token and not the refresh token upon successful login. I'm developing in a local environment and using ngrok for a callback URL.&lt;/P&gt;
&lt;P&gt;Code Snippets:&lt;/P&gt;
&lt;P&gt;- Front-end code (relevant part):&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;const handleConnect = (service) =&amp;gt; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; const connectionUrl = `${process.env.REACT_APP_HOST_URL}/auth/${service}`;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; const authWindow = window.open(connectionUrl, "_blank");&lt;BR /&gt;&amp;nbsp; &amp;nbsp; window.addEventListener('message', event =&amp;gt; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; if (event.data.message === 'Success') {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sendTokensToServer({ ...event.data, path: connectedServices[service].path });&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; authWindow.close();&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;BR /&gt;&amp;nbsp; &amp;nbsp; });&lt;BR /&gt;};&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;- Back-end code (relevant part):&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;const DropboxOAuth2Strategy = require('passport-dropbox-oauth2').Strategy;&lt;/P&gt;
&lt;P&gt;passport.use(&lt;BR /&gt;&amp;nbsp; &amp;nbsp; new DropboxOAuth2Strategy(&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; apiVersion: "2",&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; callbackURL: `${process.env.CALLBACK_URL}/oauth/dropbox/callback`,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; clientID: process.env.DROPBOX_CLIENT_ID,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; clientSecret: process.env.DROPBOX_CLIENT_SECRET,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Missing option?&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; },&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; (accessToken, refreshToken, profile, cb) =&amp;gt; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; console.log(accessToken, refreshToken)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cb(null, profile);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;BR /&gt;&amp;nbsp; &amp;nbsp; )&lt;BR /&gt;);&lt;/P&gt;
&lt;P&gt;router.get("/auth/dropbox", passport.authenticate("dropbox-oauth2"));&lt;/P&gt;
&lt;P&gt;router.get("/oauth/dropbox/callback",&lt;BR /&gt;&amp;nbsp; &amp;nbsp; passport.authenticate("dropbox-oauth2", { failureRedirect: "/" }),&lt;BR /&gt;&amp;nbsp; &amp;nbsp; (req, res) =&amp;gt; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; res.redirect("/success?service=Dropbox");&lt;BR /&gt;&amp;nbsp; &amp;nbsp; }&lt;BR /&gt;);&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;- Question:&lt;/P&gt;
&lt;P&gt;* Is using ngrok as a callback URL in my local environment preventing me from receiving the refresh token?&lt;BR /&gt;* If not, what could be causing the missing refresh token?&lt;BR /&gt;* Are there any additional configuration options needed for the `DropboxOAuth2Strategy` to obtain the refresh token?&lt;/P&gt;
&lt;P&gt;- Additional Information:&lt;/P&gt;
&lt;P&gt;* I've checked the Dropbox API documentation for OAuth2 and ensured my code is following the steps correctly.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Thanks in advance for any help!&lt;/P&gt;</description>
    <pubDate>Tue, 14 May 2024 17:54:29 GMT</pubDate>
    <dc:creator>belt_basya</dc:creator>
    <dc:date>2024-05-14T17:54:29Z</dc:date>
    <item>
      <title>Trouble Obtaining Refresh Token Alongside Access Token from Dropbox OAuth2 in Local Environment</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Trouble-Obtaining-Refresh-Token-Alongside-Access-Token-from/m-p/770551#M33690</link>
      <description>&lt;P&gt;I'm trying to integrate Dropbox into my web application using OAuth2. My code seems to be working correctly, but I'm only receiving the access token and not the refresh token upon successful login. I'm developing in a local environment and using ngrok for a callback URL.&lt;/P&gt;
&lt;P&gt;Code Snippets:&lt;/P&gt;
&lt;P&gt;- Front-end code (relevant part):&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;const handleConnect = (service) =&amp;gt; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; const connectionUrl = `${process.env.REACT_APP_HOST_URL}/auth/${service}`;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; const authWindow = window.open(connectionUrl, "_blank");&lt;BR /&gt;&amp;nbsp; &amp;nbsp; window.addEventListener('message', event =&amp;gt; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; if (event.data.message === 'Success') {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sendTokensToServer({ ...event.data, path: connectedServices[service].path });&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; authWindow.close();&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;BR /&gt;&amp;nbsp; &amp;nbsp; });&lt;BR /&gt;};&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;- Back-end code (relevant part):&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;const DropboxOAuth2Strategy = require('passport-dropbox-oauth2').Strategy;&lt;/P&gt;
&lt;P&gt;passport.use(&lt;BR /&gt;&amp;nbsp; &amp;nbsp; new DropboxOAuth2Strategy(&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; apiVersion: "2",&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; callbackURL: `${process.env.CALLBACK_URL}/oauth/dropbox/callback`,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; clientID: process.env.DROPBOX_CLIENT_ID,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; clientSecret: process.env.DROPBOX_CLIENT_SECRET,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Missing option?&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; },&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; (accessToken, refreshToken, profile, cb) =&amp;gt; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; console.log(accessToken, refreshToken)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cb(null, profile);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;BR /&gt;&amp;nbsp; &amp;nbsp; )&lt;BR /&gt;);&lt;/P&gt;
&lt;P&gt;router.get("/auth/dropbox", passport.authenticate("dropbox-oauth2"));&lt;/P&gt;
&lt;P&gt;router.get("/oauth/dropbox/callback",&lt;BR /&gt;&amp;nbsp; &amp;nbsp; passport.authenticate("dropbox-oauth2", { failureRedirect: "/" }),&lt;BR /&gt;&amp;nbsp; &amp;nbsp; (req, res) =&amp;gt; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; res.redirect("/success?service=Dropbox");&lt;BR /&gt;&amp;nbsp; &amp;nbsp; }&lt;BR /&gt;);&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;- Question:&lt;/P&gt;
&lt;P&gt;* Is using ngrok as a callback URL in my local environment preventing me from receiving the refresh token?&lt;BR /&gt;* If not, what could be causing the missing refresh token?&lt;BR /&gt;* Are there any additional configuration options needed for the `DropboxOAuth2Strategy` to obtain the refresh token?&lt;/P&gt;
&lt;P&gt;- Additional Information:&lt;/P&gt;
&lt;P&gt;* I've checked the Dropbox API documentation for OAuth2 and ensured my code is following the steps correctly.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Thanks in advance for any help!&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2024 17:54:29 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Trouble-Obtaining-Refresh-Token-Alongside-Access-Token-from/m-p/770551#M33690</guid>
      <dc:creator>belt_basya</dc:creator>
      <dc:date>2024-05-14T17:54:29Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble Obtaining Refresh Token Alongside Access Token from Dropbox OAuth2 in Local Environment</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Trouble-Obtaining-Refresh-Token-Alongside-Access-Token-from/m-p/770596#M33691</link>
      <description>&lt;P&gt;[Cross-linking for reference: &lt;A href="https://stackoverflow.com/questions/78479669/trouble-obtaining-refresh-token-alongside-access-token-from-dropbox-oauth2-in-lo" target="_blank"&gt;https://stackoverflow.com/questions/78479669/trouble-obtaining-refresh-token-alongside-access-token-from-dropbox-oauth2-in-lo&lt;/A&gt; ]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="comment-copy"&gt;Whether or not you use a redirect URI, as well as where/how the redirect URI is hosted, doesn't affect whether or not a refresh token is returned.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="comment-copy"&gt;In order to get a refresh token from Dropbox, you need to set &lt;CODE&gt;token_access_type=offline&lt;/CODE&gt; on &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#oauth2-authorize" rel="nofollow noreferrer" target="_blank"&gt;/oauth2/authorize&lt;/A&gt;. I don't see that in your code, so you'll need to check on whether your OAuth library automatically does that for you, and if not, how you can set it.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="comment-copy"&gt;W can't offer support for the DropboxOAuth2Strategy class as that's not written by Dropbox. I suggest referring to the documentation for it.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2024 20:33:05 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Trouble-Obtaining-Refresh-Token-Alongside-Access-Token-from/m-p/770596#M33691</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2024-05-14T20:33:05Z</dc:date>
    </item>
  </channel>
</rss>

