<?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: Refresh token not valid in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Refresh-token-not-valid/m-p/642067#M29542</link>
    <description>&lt;P&gt;Hi &lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1597992"&gt;@MightyModest&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;You are doing well initial authorization steps! &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; So, you already have all needed to be able perform regular API calls. The API calls accept access tokens only, NOT refresh token!!! That's where start your errors. First, don't try replace the access token with refresh token - as you know already it doesn't work. Second as "refresh token" name suggest, it's a token to refresh the access token and can't be used for something else. &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; By the way... &lt;img class="lia-deferred-image lia-image-emoji" src="https://www.dropboxforum.com/html/@9AD39CA637682E9616FBE31CDAF1B6C4/emoticons/1f914.png" alt=":thinking_face:" title=":thinking_face:" /&gt; have you refreshed the access token once the initial one got expire? Ohh... 🤫 seems not! Try it - may work. &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; Take a look &lt;A href="https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Issue-in-generating-access-token/m-p/592667" target="_blank" rel="noopener"&gt;here&lt;/A&gt; for a more complete example.&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
    <pubDate>Wed, 07 Dec 2022 00:52:58 GMT</pubDate>
    <dc:creator>Здравко</dc:creator>
    <dc:date>2022-12-07T00:52:58Z</dc:date>
    <item>
      <title>Refresh token not valid</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Refresh-token-not-valid/m-p/642037#M29541</link>
      <description>&lt;P&gt;I'm building a Flask app that sends files users post on their account to a shared Dropbox folder. It works fine with these short-lived 4-hour tokens, but as I prepare to move to deployment I need a longer-lasting token. I got a refresh token but when I try to use it I get an invalid token exception. I did the following:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Used my browser to load the following, with my app key inserted.&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="markup"&gt;https://www.dropbox.com/oauth2/authorize?client_id=APPKEYHERE&amp;amp;response_type=code&amp;amp;token_access_type=offline&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;2. Authorized the request in the browser, got back the access code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. Ran the following, inserting the code I just got in the previous step, as well as my app key and app secret:&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="markup"&gt;curl https://api.dropbox.com/oauth2/token \
    -d code=CODE_I_JUST_GOT_FROM_BROWSER \
    -d grant_type=authorization_code \
    -u APPKEYHERE:APPSECRETHERE&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;This returned what I expect—a dictionary with access token (the short-lived one starting with `sl.`), some account and permission info, and the `refresh_token`. When I use the short lived token it works (until expiration) but the refresh token gives me an error. What am I doing incorrectly? I've done the above process a couple of times now with no luck.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 08:10:28 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Refresh-token-not-valid/m-p/642037#M29541</guid>
      <dc:creator>MightyModest</dc:creator>
      <dc:date>2022-12-07T08:10:28Z</dc:date>
    </item>
    <item>
      <title>Re: Refresh token not valid</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Refresh-token-not-valid/m-p/642067#M29542</link>
      <description>&lt;P&gt;Hi &lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1597992"&gt;@MightyModest&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;You are doing well initial authorization steps! &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; So, you already have all needed to be able perform regular API calls. The API calls accept access tokens only, NOT refresh token!!! That's where start your errors. First, don't try replace the access token with refresh token - as you know already it doesn't work. Second as "refresh token" name suggest, it's a token to refresh the access token and can't be used for something else. &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; By the way... &lt;img class="lia-deferred-image lia-image-emoji" src="https://www.dropboxforum.com/html/@9AD39CA637682E9616FBE31CDAF1B6C4/emoticons/1f914.png" alt=":thinking_face:" title=":thinking_face:" /&gt; have you refreshed the access token once the initial one got expire? Ohh... 🤫 seems not! Try it - may work. &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; Take a look &lt;A href="https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Issue-in-generating-access-token/m-p/592667" target="_blank" rel="noopener"&gt;here&lt;/A&gt; for a more complete example.&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 00:52:58 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Refresh-token-not-valid/m-p/642067#M29542</guid>
      <dc:creator>Здравко</dc:creator>
      <dc:date>2022-12-07T00:52:58Z</dc:date>
    </item>
    <item>
      <title>Re: Refresh token not valid</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Refresh-token-not-valid/m-p/642225#M29546</link>
      <description>&lt;P&gt;Thanks for clarifying on the refresh token. I think my confusion is about how to implement a Python-specific way of using that refresh token to constantly grab a new short-lived token. Right now my app does the following (which works with a short-lived token in my environmental variables):&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import dropbox

client = dropbox.Dropbox(dropbox_access_token)
uploaded = client.files_upload(open(local_file_path, "rb").read(), dropbox_path)
shared_link = client.sharing_create_shared_link(dropbox_path)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've searched for an example of how I can programmatically (I imagine via a cron job that runs more frequently than the four hour expiration time) use my refresh token to update `dropbox_access_token` above. I'm sure there's a code example but I just can't find it, likely because I'm not using the right terminology.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 14:45:22 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Refresh-token-not-valid/m-p/642225#M29546</guid>
      <dc:creator>MightyModest</dc:creator>
      <dc:date>2022-12-07T14:45:22Z</dc:date>
    </item>
    <item>
      <title>Re: Refresh token not valid</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Refresh-token-not-valid/m-p/642228#M29547</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1597992"&gt;@MightyModest&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;... I think my confusion is about how to implement a Python-specific way of using that refresh token to constantly grab a new short-lived token. ... I've searched for an example of how I can programmatically (I imagine via a cron job that runs more frequently than the four hour expiration time) use my refresh token to update `dropbox_access_token` above. ...&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;img class="lia-deferred-image lia-image-emoji" src="https://www.dropboxforum.com/html/@488936AC5FA64023548E32631AFD9803/emoticons/1f600.png" alt=":grinning_face:" title=":grinning_face:" /&gt; No, you will not find such a example and it's not need while using any of Dropbox supported SDKs (including Python). Refresh is performed by the client object internally whenever needed - on demand. The only thing you need is to provide full credentials (including refresh token), so refresh to be possible. &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; Take a look &lt;A href="https://github.com/dropbox/dropbox-sdk-python/blob/main/example/oauth/commandline-oauth-pkce.py#L25" target="_blank" rel="noopener"&gt;here&lt;/A&gt; for a something like very simple example. Don't try perform refresh yourself; in such a way you will double existing code - something meaningless. Ahh.. it's still possible of course...&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 15:01:26 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Refresh-token-not-valid/m-p/642228#M29547</guid>
      <dc:creator>Здравко</dc:creator>
      <dc:date>2022-12-07T15:01:26Z</dc:date>
    </item>
    <item>
      <title>Re: Refresh token not valid</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Refresh-token-not-valid/m-p/642305#M29550</link>
      <description>&lt;P&gt;&lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1597992"&gt;@MightyModest&lt;/a&gt; As Здравко noted, if you're using an official Dropbox SDK, you don't need to implement the refresh process yourself. The SDK will do that for you automatically as long as you provide the necessary credentials. For reference, in &lt;A href="https://github.com/dropbox/dropbox-sdk-python/blob/main/example/oauth/commandline-oauth-pkce.py#L25" target="_blank"&gt;the PKCE example Здравко linked to&lt;/A&gt;, only the refresh token and app key is required. If you're not using PKCE to retrieve the refresh token initially though, you'll need to also supply the app secret, as in &lt;A href="https://github.com/dropbox/dropbox-sdk-python/blob/main/example/oauth/commandline-oauth-scopes.py#L79" target="_blank"&gt;this example&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 19:13:10 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Refresh-token-not-valid/m-p/642305#M29550</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2022-12-07T19:13:10Z</dc:date>
    </item>
  </channel>
</rss>

