<?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: Access Token Can't be refreshed without refresh token and app key in Python in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-Token-Can-t-be-refreshed-without-refresh-token-and-app/m-p/646688#M29668</link>
    <description>&lt;P&gt;In order to get this working, please set up the client by supplying the refresh token, etc., to it directly, as shown in &lt;A href="https://github.com/dropbox/dropbox-sdk-python/blob/main/example/oauth/commandline-oauth-scopes.py#L79" target="_blank"&gt;the example&lt;/A&gt;, so that it can perform the refresh process for you. That way, it can continue performing API calls successfully for more than four hours.&lt;/P&gt;</description>
    <pubDate>Tue, 27 Dec 2022 16:54:33 GMT</pubDate>
    <dc:creator>Greg-DB</dc:creator>
    <dc:date>2022-12-27T16:54:33Z</dc:date>
    <item>
      <title>Access Token Can't be refreshed without refresh token and app key in Python</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-Token-Can-t-be-refreshed-without-refresh-token-and-app/m-p/646648#M29661</link>
      <description>&lt;P&gt;I am building an app in python to automatically update a file using dropbox API, but it shows an error after 4 hours however I can't find any mistake can you point out my mistake? My code Link:&amp;nbsp;&lt;A href="https://github.com/sufiyanashraf/dropboxhelp/blob/main/cantrefresh" target="_blank"&gt;https://github.com/sufiyanashraf/dropboxhelp/blob/main/cantrefresh&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Dec 2022 14:46:54 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-Token-Can-t-be-refreshed-without-refresh-token-and-app/m-p/646648#M29661</guid>
      <dc:creator>Sufiyanashraf</dc:creator>
      <dc:date>2022-12-27T14:46:54Z</dc:date>
    </item>
    <item>
      <title>Re: Access Token Can't be refreshed without refresh token and app key in Python</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-Token-Can-t-be-refreshed-without-refresh-token-and-app/m-p/646662#M29663</link>
      <description>&lt;P&gt;I see you are using the &lt;A href="https://github.com/dropbox/dropbox-sdk-python" target="_blank"&gt;official Dropbox Python SDK&lt;/A&gt; to do the upload work, but are attempting to perform the refresh process yourself using 'requests' to call the /oauth2/token endpoint directly. The official Dropbox Python SDK can handle the refresh process for you automatically though, and I strongly recommend having it do so instead of attempting to implement the refresh process yourself. You can see &lt;A href="https://github.com/dropbox/dropbox-sdk-python/blob/main/example/oauth/commandline-oauth-scopes.py#L79" target="_blank"&gt;an example of supplying the credentials to the Dropbox object here&lt;/A&gt;, in which case it will handle the refresh for you automatically.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Dec 2022 15:17:18 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-Token-Can-t-be-refreshed-without-refresh-token-and-app/m-p/646662#M29663</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2022-12-27T15:17:18Z</dc:date>
    </item>
    <item>
      <title>Re: Access Token Can't be refreshed without refresh token and app key in Python</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-Token-Can-t-be-refreshed-without-refresh-token-and-app/m-p/646669#M29667</link>
      <description>&lt;P&gt;Yes, but it is just setup nothing related to token refresh. basically, my software stopped after 4 hours first it showed the error of an expired access token. So, I used this method by searching. Can you please point out the corrections in my code?&lt;/P&gt;</description>
      <pubDate>Tue, 27 Dec 2022 15:49:54 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-Token-Can-t-be-refreshed-without-refresh-token-and-app/m-p/646669#M29667</guid>
      <dc:creator>Sufiyanashraf</dc:creator>
      <dc:date>2022-12-27T15:49:54Z</dc:date>
    </item>
    <item>
      <title>Re: Access Token Can't be refreshed without refresh token and app key in Python</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-Token-Can-t-be-refreshed-without-refresh-token-and-app/m-p/646688#M29668</link>
      <description>&lt;P&gt;In order to get this working, please set up the client by supplying the refresh token, etc., to it directly, as shown in &lt;A href="https://github.com/dropbox/dropbox-sdk-python/blob/main/example/oauth/commandline-oauth-scopes.py#L79" target="_blank"&gt;the example&lt;/A&gt;, so that it can perform the refresh process for you. That way, it can continue performing API calls successfully for more than four hours.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Dec 2022 16:54:33 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-Token-Can-t-be-refreshed-without-refresh-token-and-app/m-p/646688#M29668</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2022-12-27T16:54:33Z</dc:date>
    </item>
    <item>
      <title>Re: Access Token Can't be refreshed without refresh token and app key in Python</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-Token-Can-t-be-refreshed-without-refresh-token-and-app/m-p/646692#M29669</link>
      <description>&lt;P&gt;So flow like this? It still shows an error.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;import sys
import dropbox
import time
from dropbox import DropboxOAuth2FlowNoRedirect
from dropbox.files import WriteMode

while True:
    with dropbox.Dropbox(oauth2_access_token='access token',
                     oauth2_access_token_expiration=expiry,
                     oauth2_refresh_token='refresh token',
                     app_key='app key',
                     app_secret='secret'):
        try:
            with open('rtk.txt', 'rb') as f:
                file_contents = f.read()   
            dbx.files_upload(file_contents, '/rtk.txt', mode=dropbox.files.WriteMode('overwrite'))
        except Exception as e:
            print(f"An error occurred: {e}")
    time.sleep(60)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Error:&amp;nbsp;An error occurred: name 'dbx' is not defined&lt;/P&gt;</description>
      <pubDate>Tue, 27 Dec 2022 17:15:49 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-Token-Can-t-be-refreshed-without-refresh-token-and-app/m-p/646692#M29669</guid>
      <dc:creator>Sufiyanashraf</dc:creator>
      <dc:date>2022-12-27T17:15:49Z</dc:date>
    </item>
    <item>
      <title>Re: Access Token Can't be refreshed without refresh token and app key in Python</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-Token-Can-t-be-refreshed-without-refresh-token-and-app/m-p/646697#M29670</link>
      <description>&lt;P&gt;That error indicates that you're attempting to use an object that isn't defined. Since you're trying to access a client with the name "dbx", add "as dbx" at the end of the "with" statement (before the ":"), like this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;    with dropbox.Dropbox(oauth2_access_token='access token',
                     oauth2_access_token_expiration=expiry,
                     oauth2_refresh_token='refresh token',
                     app_key='app key',
                     app_secret='secret') as dbx:&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;(Or, you can still do it the other way, like "dbx = dropbox.Dropbox(...)" as long as you fill in credentials like above.)&lt;/P&gt;</description>
      <pubDate>Tue, 27 Dec 2022 17:43:45 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-Token-Can-t-be-refreshed-without-refresh-token-and-app/m-p/646697#M29670</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2022-12-27T17:43:45Z</dc:date>
    </item>
    <item>
      <title>Re: Access Token Can't be refreshed without refresh token and app key in Python</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-Token-Can-t-be-refreshed-without-refresh-token-and-app/m-p/646700#M29671</link>
      <description>&lt;P&gt;I corrected but again error&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import sys
import dropbox
from dropbox import DropboxOAuth2FlowNoRedirect
from dropbox.files import WriteMode
import time

while True:
    with dropbox.Dropbox(oauth2_access_token='sl access token',
                     oauth2_access_token_expiration=14400,
                     oauth2_refresh_token='refresh token',
                     app_key='app key',
                     app_secret='app secret') as dbx:
        try:
            with open('rtk.txt', 'rb') as f:
                file_contents = f.read()   
            dbx.files_upload(file_contents, '/rtk.txt', mode=dropbox.files.WriteMode('overwrite'))
        except Exception as e:
            print(f"An error occurred: {e}")
    time.sleep(60)&lt;/LI-CODE&gt;&lt;P&gt;Showing error: "An error occurred: '&amp;gt;=' not supported between instances of 'datetime.datetime' and 'int'"&lt;/P&gt;</description>
      <pubDate>Tue, 27 Dec 2022 18:02:28 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-Token-Can-t-be-refreshed-without-refresh-token-and-app/m-p/646700#M29671</guid>
      <dc:creator>Sufiyanashraf</dc:creator>
      <dc:date>2022-12-27T18:02:28Z</dc:date>
    </item>
    <item>
      <title>Re: Access Token Can't be refreshed without refresh token and app key in Python</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-Token-Can-t-be-refreshed-without-refresh-token-and-app/m-p/646707#M29672</link>
      <description>&lt;P&gt;This error is indicating that oauth2_access_token_expiration requires a datetime, but you're now passing in an int. You should pass in a datetime for that. Or, you can just omit oauth2_access_token_expiration entirely and the SDK will just handle it as needed.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Dec 2022 18:24:56 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-Token-Can-t-be-refreshed-without-refresh-token-and-app/m-p/646707#M29672</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2022-12-27T18:24:56Z</dc:date>
    </item>
    <item>
      <title>Re: Access Token Can't be refreshed without refresh token and app key in Python</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-Token-Can-t-be-refreshed-without-refresh-token-and-app/m-p/646708#M29673</link>
      <description>&lt;P&gt;Remove this line?&amp;nbsp;&lt;/P&gt;&lt;P&gt;oauth2_access_token_expiration=14400,&lt;/P&gt;</description>
      <pubDate>Tue, 27 Dec 2022 18:28:44 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-Token-Can-t-be-refreshed-without-refresh-token-and-app/m-p/646708#M29673</guid>
      <dc:creator>Sufiyanashraf</dc:creator>
      <dc:date>2022-12-27T18:28:44Z</dc:date>
    </item>
    <item>
      <title>Re: Access Token Can't be refreshed without refresh token and app key in Python</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-Token-Can-t-be-refreshed-without-refresh-token-and-app/m-p/646709#M29674</link>
      <description>&lt;P&gt;Yes, either remove it or supply the correct type (datetime).&lt;/P&gt;</description>
      <pubDate>Tue, 27 Dec 2022 18:33:01 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-Token-Can-t-be-refreshed-without-refresh-token-and-app/m-p/646709#M29674</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2022-12-27T18:33:01Z</dc:date>
    </item>
    <item>
      <title>Re: Access Token Can't be refreshed without refresh token and app key in Python</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-Token-Can-t-be-refreshed-without-refresh-token-and-app/m-p/646712#M29675</link>
      <description>&lt;P&gt;For now this code is perfectly working but I still want to open this topic 4 hours more to confirm if program doesn't die after that!&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import sys
import dropbox
from dropbox import DropboxOAuth2FlowNoRedirect
from dropbox.files import WriteMode
import time

while True:
    with dropbox.Dropbox(oauth2_access_token='&amp;lt;access token&amp;gt;',
                     oauth2_refresh_token='&amp;lt;refresh token&amp;gt;',
                     app_key='&amp;lt;app key&amp;gt;',
                     app_secret='&amp;lt;app secret&amp;gt;') as dbx:
        try:
            with open('rtk.txt', 'rb') as f:
                file_contents = f.read()   
            dbx.files_upload(file_contents, '/rtk.txt', mode=dropbox.files.WriteMode('overwrite'))
        except Exception as e:
            print(f"An error occurred: {e}")
    time.sleep(60)&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 27 Dec 2022 18:36:27 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Access-Token-Can-t-be-refreshed-without-refresh-token-and-app/m-p/646712#M29675</guid>
      <dc:creator>Sufiyanashraf</dc:creator>
      <dc:date>2022-12-27T18:36:27Z</dc:date>
    </item>
  </channel>
</rss>

