<?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: Python API Short-lived access token for Dropbox in Discuss Dropbox Developer &amp; API</title>
    <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Python-API-Short-lived-access-token-for-Dropbox/m-p/754252#M3934</link>
    <description>&lt;P&gt;Hi &lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1809311"&gt;@PHAnetwork&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Your code looks fine. There is not something wrong. Important thing is what are you doing later with the result though! If I have to bet, you have some mistake on client object initialization. Make review there. &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; Did you by any chance skip refresh token there? 🙋&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;</description>
    <pubDate>Thu, 29 Feb 2024 21:05:53 GMT</pubDate>
    <dc:creator>Здравко</dc:creator>
    <dc:date>2024-02-29T21:05:53Z</dc:date>
    <item>
      <title>Python API Short-lived access token for Dropbox</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Python-API-Short-lived-access-token-for-Dropbox/m-p/754237#M3933</link>
      <description>&lt;P&gt;I may not be fully understanding this, but here's the issue. I'm trying to get a short-lived token that can be used repeatedly. The first time through, I am prompting through the command line. I can get the token from Dropbox and when I test it (using files_list_folder) it works.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, if I try to then use that token on subsequent Dropbox API calls, I get invalid_access_token.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code I am using to get the access token.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;    def get_token_no_redirect(self):
        oauth_result = ""
        auth_flow = oauth.DropboxOAuth2FlowNoRedirect(consumer_key=self.app_key, consumer_secret=self.app_secret,
                                                      token_access_type="offline")
        authorize_url = auth_flow.start()
        print(f"1. Go to: {authorize_url})")
        print("2. Click \\Allow\\ (you might have to log in first).")
        print("3. Copy the authorization code.")
        auth_code = input("Enter the authorization code here: ").strip()
        try:
            oauth_result = auth_flow.finish(auth_code)
        except Exception as e:
            print('Error: %s' % (e,))
        return oauth_result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also tried this sending "online" instead but still got the error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there another way to get a token that can then be used on future requests?&lt;/P&gt;</description>
      <pubDate>Thu, 29 Feb 2024 19:33:24 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Python-API-Short-lived-access-token-for-Dropbox/m-p/754237#M3933</guid>
      <dc:creator>PHAnetwork</dc:creator>
      <dc:date>2024-02-29T19:33:24Z</dc:date>
    </item>
    <item>
      <title>Re: Python API Short-lived access token for Dropbox</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Python-API-Short-lived-access-token-for-Dropbox/m-p/754252#M3934</link>
      <description>&lt;P&gt;Hi &lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1809311"&gt;@PHAnetwork&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Your code looks fine. There is not something wrong. Important thing is what are you doing later with the result though! If I have to bet, you have some mistake on client object initialization. Make review there. &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; Did you by any chance skip refresh token there? 🙋&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Feb 2024 21:05:53 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Python-API-Short-lived-access-token-for-Dropbox/m-p/754252#M3934</guid>
      <dc:creator>Здравко</dc:creator>
      <dc:date>2024-02-29T21:05:53Z</dc:date>
    </item>
    <item>
      <title>Re: Python API Short-lived access token for Dropbox</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Python-API-Short-lived-access-token-for-Dropbox/m-p/754255#M3935</link>
      <description>&lt;P&gt;Thanks for the reply!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, what I'm doing is capturing the generated access token, and then trying to use that later on. Here is the code that uses that token.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;access_token = "{ACCESS_TOKEN_PASTED_HERE}"
dbx = Dropbox(access_token)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I copy the token generated in the previous Python code and then paste it here. The token works once on the initial generation, but if I try to use the same token a second time it shows as invalid.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does that mean that this is NOT a short-lived access token? Do I need to refresh this token in the example here and if so, how do I do that with the Python API. I couldn't find anything in the documents about this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 29 Feb 2024 21:15:50 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Python-API-Short-lived-access-token-for-Dropbox/m-p/754255#M3935</guid>
      <dc:creator>PHAnetwork</dc:creator>
      <dc:date>2024-02-29T21:15:50Z</dc:date>
    </item>
    <item>
      <title>Re: Python API Short-lived access token for Dropbox</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Python-API-Short-lived-access-token-for-Dropbox/m-p/754258#M3936</link>
      <description>&lt;P&gt;&lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1809311"&gt;@PHAnetwork&lt;/a&gt;, What is the meaning of word "short" (either about token or whatever else)? 🧐&lt;/P&gt;&lt;P&gt;Of course, I hope you know. In the same context why are you surprised that a &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;short&lt;/STRONG&gt;&lt;/FONT&gt;-lived access token expires?&lt;/P&gt;&lt;P&gt;Your code is wrong (the second part) of course. As I supposed you have skipped the refresh token (part of the result also). In addition you have to add the applications key and secret (needed for automated token refreshing).&lt;/P&gt;&lt;P&gt;Hope this gives direction.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Feb 2024 21:22:30 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Python-API-Short-lived-access-token-for-Dropbox/m-p/754258#M3936</guid>
      <dc:creator>Здравко</dc:creator>
      <dc:date>2024-02-29T21:22:30Z</dc:date>
    </item>
    <item>
      <title>Re: Python API Short-lived access token for Dropbox</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Python-API-Short-lived-access-token-for-Dropbox/m-p/754263#M3937</link>
      <description>&lt;P&gt;Actually, it's the &lt;STRONG&gt;Refresh Token&lt;/STRONG&gt; process that I'm struggling with. I can't seem to find out how to request a refresh token using the Python API.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Feb 2024 21:26:24 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Python-API-Short-lived-access-token-for-Dropbox/m-p/754263#M3937</guid>
      <dc:creator>PHAnetwork</dc:creator>
      <dc:date>2024-02-29T21:26:24Z</dc:date>
    </item>
    <item>
      <title>Re: Python API Short-lived access token for Dropbox</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Python-API-Short-lived-access-token-for-Dropbox/m-p/754265#M3938</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/422790"&gt;@Здравко&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;... As I supposed you have skipped the refresh token (&lt;FONT color="#008000"&gt;part of the result also&lt;/FONT&gt;). ...&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1809311"&gt;@PHAnetwork&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;... I can't seem to find out &lt;FONT color="#FF0000"&gt;how to request a refresh token&lt;/FONT&gt; using the Python API.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Do I need to say (or rather repeat) that you have it done already? &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;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Feb 2024 21:30:46 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Python-API-Short-lived-access-token-for-Dropbox/m-p/754265#M3938</guid>
      <dc:creator>Здравко</dc:creator>
      <dc:date>2024-02-29T21:30:46Z</dc:date>
    </item>
    <item>
      <title>Re: Python API Short-lived access token for Dropbox</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Python-API-Short-lived-access-token-for-Dropbox/m-p/754266#M3939</link>
      <description>&lt;P&gt;Okay, still confused.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You said, "&lt;SPAN&gt;As I supposed you have skipped the refresh token" and then you said, "I have done it already". Did I skip the refresh token, or did I do it correctly?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Sorry, but your reply really didn't help.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Feb 2024 21:34:34 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Python-API-Short-lived-access-token-for-Dropbox/m-p/754266#M3939</guid>
      <dc:creator>PHAnetwork</dc:creator>
      <dc:date>2024-02-29T21:34:34Z</dc:date>
    </item>
    <item>
      <title>Re: Python API Short-lived access token for Dropbox</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Python-API-Short-lived-access-token-for-Dropbox/m-p/754268#M3940</link>
      <description>&lt;P&gt;Nobody can help you when you don't read your own writings!&lt;/P&gt;&lt;P&gt;Yes, you have requested and received refresh token (offline declaration is enough), but later skipped it. You have fetched from the result only access token, but not the refresh token!&amp;nbsp;🤦 Why?&lt;/P&gt;&lt;P&gt;I cannot say it clearer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PS: The example &lt;A href="https://github.com/dropbox/dropbox-sdk-python/blob/main/example/oauth/commandline-oauth-scopes.py#L79" target="_blank" rel="noopener"&gt;here&lt;/A&gt; shows how you can do it - to initialize client object from oauth result.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Feb 2024 21:52:22 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Python-API-Short-lived-access-token-for-Dropbox/m-p/754268#M3940</guid>
      <dc:creator>Здравко</dc:creator>
      <dc:date>2024-02-29T21:52:22Z</dc:date>
    </item>
    <item>
      <title>Re: Python API Short-lived access token for Dropbox</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Python-API-Short-lived-access-token-for-Dropbox/m-p/754275#M3941</link>
      <description>&lt;P&gt;Okay, I see the problem, and now realize that it's time for me to retire from this business&lt;img class="lia-deferred-image lia-image-emoji" src="https://www.dropboxforum.com/html/@FA89D49CABCE2F340F69DC63E5034A89/emoticons/1f614.png" alt=":pensive_face:" title=":pensive_face:" /&gt;!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was pasting the initial code from the Dropbox authorization section, which is used to obtain the access token instead of the actual access token. That's where the confusion was. I'm familiar with what the access token should look like, so I'm not sure why I didn't recognize that earlier.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's working now. Thanks for your help and patience!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Feb 2024 21:52:59 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Python-API-Short-lived-access-token-for-Dropbox/m-p/754275#M3941</guid>
      <dc:creator>PHAnetwork</dc:creator>
      <dc:date>2024-02-29T21:52:59Z</dc:date>
    </item>
  </channel>
</rss>

