<?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 Python error when setting up access for my App to Dropbox account in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Python-error-when-setting-up-access-for-my-App-to-Dropbox/m-p/24800#M730</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I'm new to this and need some help with setting up access with my Dropbox app to a Dropbox account using Python. When running the code I get the error shown below. I have inserted the app and secret codes into it. Plus the app has an API token. Any guidance would be greatly appreciated.&lt;/P&gt;

&lt;P&gt;See python code below error message.&lt;/P&gt;

&lt;H1&gt;Error message&lt;/H1&gt;

&lt;P&gt;Traceback (most recent call last):&lt;/P&gt;

&lt;P&gt;&amp;nbsp; File "dropbox_test.py", line 2, in &amp;lt;module&amp;gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; import dropbox&lt;/P&gt;

&lt;P&gt;&amp;nbsp; File "/Users/ninekay/Desktop/Python/dropbox.py", line 24&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; client = dropbox.client.DropboxClient(access_token)&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;H1&gt;Python code being used&lt;/H1&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;H1&gt;&lt;STRONG&gt;Include the Dropbox SDK&lt;/STRONG&gt;&lt;/H1&gt;

&lt;P&gt;import dropbox&lt;/P&gt;

&lt;H1&gt;Get your app key and secret from the Dropbox developer website&lt;/H1&gt;

&lt;P&gt;app_key = 'qdrn1l679o14y86'&lt;/P&gt;

&lt;P&gt;app_secret = '&amp;lt;redacted&amp;gt;'&lt;/P&gt;

&lt;P&gt;flow = dropbox.client.DropboxOAuth2FlowNoRedirect(app_key, app_secret)&lt;/P&gt;

&lt;H1&gt;Have the user sign in and authorize this token&lt;/H1&gt;

&lt;P&gt;authorize_url = flow.start()&lt;/P&gt;

&lt;P&gt;print '1. Go to: ' + authorize_url&lt;/P&gt;

&lt;P&gt;print '2. Click "Allow" (you might have to log in first)'&lt;/P&gt;

&lt;P&gt;print '3. Copy the authorization code.'&lt;/P&gt;

&lt;P&gt;code = raw_input("Enter the authorization code here: ").strip()&lt;/P&gt;

&lt;H1&gt;This will fail if the user enters an invalid authorization code&lt;/H1&gt;

&lt;P&gt;access_token, user_id = flow.finish(code)&lt;/P&gt;

&lt;P&gt;client = dropbox.client.DropboxClient(access_token)&lt;/P&gt;

&lt;P&gt;print 'linked account: ', client.account_info()&lt;/P&gt;

&lt;P&gt;f = open('working-draft.txt', 'rb')&lt;/P&gt;

&lt;P&gt;response = client.put_file('/magnum-opus.txt', f)&lt;/P&gt;

&lt;P&gt;print 'uploaded: ', response&lt;/P&gt;

&lt;P&gt;folder_metadata = client.metadata('/')&lt;/P&gt;

&lt;P&gt;print 'metadata: ', folder_metadata&lt;/P&gt;

&lt;P&gt;f, metadata = client.get_file_and_metadata('/magnum-opus.txt')&lt;/P&gt;

&lt;P&gt;out = open('magnum-opus.txt', 'wb')&lt;/P&gt;

&lt;P&gt;out.write(f.read())&lt;/P&gt;

&lt;P&gt;out.close()&lt;/P&gt;

&lt;P&gt;print metadata&lt;/P&gt;</description>
    <pubDate>Wed, 29 May 2019 09:40:44 GMT</pubDate>
    <dc:creator>Mobistudios A.</dc:creator>
    <dc:date>2019-05-29T09:40:44Z</dc:date>
    <item>
      <title>Python error when setting up access for my App to Dropbox account</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Python-error-when-setting-up-access-for-my-App-to-Dropbox/m-p/24800#M730</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I'm new to this and need some help with setting up access with my Dropbox app to a Dropbox account using Python. When running the code I get the error shown below. I have inserted the app and secret codes into it. Plus the app has an API token. Any guidance would be greatly appreciated.&lt;/P&gt;

&lt;P&gt;See python code below error message.&lt;/P&gt;

&lt;H1&gt;Error message&lt;/H1&gt;

&lt;P&gt;Traceback (most recent call last):&lt;/P&gt;

&lt;P&gt;&amp;nbsp; File "dropbox_test.py", line 2, in &amp;lt;module&amp;gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; import dropbox&lt;/P&gt;

&lt;P&gt;&amp;nbsp; File "/Users/ninekay/Desktop/Python/dropbox.py", line 24&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; client = dropbox.client.DropboxClient(access_token)&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;H1&gt;Python code being used&lt;/H1&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;H1&gt;&lt;STRONG&gt;Include the Dropbox SDK&lt;/STRONG&gt;&lt;/H1&gt;

&lt;P&gt;import dropbox&lt;/P&gt;

&lt;H1&gt;Get your app key and secret from the Dropbox developer website&lt;/H1&gt;

&lt;P&gt;app_key = 'qdrn1l679o14y86'&lt;/P&gt;

&lt;P&gt;app_secret = '&amp;lt;redacted&amp;gt;'&lt;/P&gt;

&lt;P&gt;flow = dropbox.client.DropboxOAuth2FlowNoRedirect(app_key, app_secret)&lt;/P&gt;

&lt;H1&gt;Have the user sign in and authorize this token&lt;/H1&gt;

&lt;P&gt;authorize_url = flow.start()&lt;/P&gt;

&lt;P&gt;print '1. Go to: ' + authorize_url&lt;/P&gt;

&lt;P&gt;print '2. Click "Allow" (you might have to log in first)'&lt;/P&gt;

&lt;P&gt;print '3. Copy the authorization code.'&lt;/P&gt;

&lt;P&gt;code = raw_input("Enter the authorization code here: ").strip()&lt;/P&gt;

&lt;H1&gt;This will fail if the user enters an invalid authorization code&lt;/H1&gt;

&lt;P&gt;access_token, user_id = flow.finish(code)&lt;/P&gt;

&lt;P&gt;client = dropbox.client.DropboxClient(access_token)&lt;/P&gt;

&lt;P&gt;print 'linked account: ', client.account_info()&lt;/P&gt;

&lt;P&gt;f = open('working-draft.txt', 'rb')&lt;/P&gt;

&lt;P&gt;response = client.put_file('/magnum-opus.txt', f)&lt;/P&gt;

&lt;P&gt;print 'uploaded: ', response&lt;/P&gt;

&lt;P&gt;folder_metadata = client.metadata('/')&lt;/P&gt;

&lt;P&gt;print 'metadata: ', folder_metadata&lt;/P&gt;

&lt;P&gt;f, metadata = client.get_file_and_metadata('/magnum-opus.txt')&lt;/P&gt;

&lt;P&gt;out = open('magnum-opus.txt', 'wb')&lt;/P&gt;

&lt;P&gt;out.write(f.read())&lt;/P&gt;

&lt;P&gt;out.close()&lt;/P&gt;

&lt;P&gt;print metadata&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 09:40:44 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Python-error-when-setting-up-access-for-my-App-to-Dropbox/m-p/24800#M730</guid>
      <dc:creator>Mobistudios A.</dc:creator>
      <dc:date>2019-05-29T09:40:44Z</dc:date>
    </item>
    <item>
      <title>Re: Python error when setting up access for my App to Dropbox account</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Python-error-when-setting-up-access-for-my-App-to-Dropbox/m-p/24801#M731</link>
      <description>&lt;P&gt;Change the name of your Python file. When you do &lt;CODE&gt;import dropbox&lt;/CODE&gt;, Python is&amp;nbsp;first noticing the file &lt;CODE&gt;dropbox.py&lt;/CODE&gt; in the current directory and trying to import that. What you want it to actually do is import the Dropbox SDK, so rename your Python file to something other than &lt;CODE&gt;dropbox.py&lt;/CODE&gt;, and things should work.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Aug 2015 08:48:54 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Python-error-when-setting-up-access-for-my-App-to-Dropbox/m-p/24801#M731</guid>
      <dc:creator>Steve M.</dc:creator>
      <dc:date>2015-08-05T08:48:54Z</dc:date>
    </item>
    <item>
      <title>Re: Python error when setting up access for my App to Dropbox account</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Python-error-when-setting-up-access-for-my-App-to-Dropbox/m-p/24802#M732</link>
      <description>&lt;P&gt;&amp;nbsp;Thanks for the answer. we have made progress. Now when making any choice at the menu I get the following error.&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;Go to: &lt;A href="https://www.dropbox.com/1/oauth2/authorize?response_type=code&amp;amp;client_id=qdrn1l679o14y86" rel="nofollow noreferrer"&gt;https://www.dropbox.com/1/oauth2/authorize?response_type=code&amp;amp;client_id=qdrn1l679o14y86&lt;/A&gt;&lt;BR /&gt;
&lt;/LI&gt;
&lt;LI&gt;Click "Allow" (you might have to log in first)&lt;BR /&gt;
&lt;/LI&gt;
&lt;LI&gt;Copy the authorization code.&lt;BR /&gt;
Enter the authorization code here: 1&lt;BR /&gt;
/Library/Python/2.7/site-packages/urllib3-1.11-py2.7.egg/urllib3/util/ssl_.py:97: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see &lt;A href="https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning" rel="nofollow noreferrer"&gt;https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning&lt;/A&gt;.&lt;BR /&gt;
Traceback (most recent call last):&lt;BR /&gt;
&amp;nbsp; File "upload.py", line 18, in &amp;lt;module&amp;gt;&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; access_token, user_id = flow.finish(code)&lt;BR /&gt;
&amp;nbsp; File "/Library/Python/2.7/site-packages/dropbox-2.2.0-py2.7.egg/dropbox/client.py", line 1398, in finish&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; return self._finish(code, None)&lt;BR /&gt;
&amp;nbsp; File "/Library/Python/2.7/site-packages/dropbox-2.2.0-py2.7.egg/dropbox/client.py", line 1265, in _finish&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; response = self.rest_client.POST(url, params=params)&lt;BR /&gt;
&amp;nbsp; File "/Library/Python/2.7/site-packages/dropbox-2.2.0-py2.7.egg/dropbox/rest.py", line 316, in POST&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; return cls.IMPL.POST(*n, **kw)&lt;BR /&gt;
&amp;nbsp; File "/Library/Python/2.7/site-packages/dropbox-2.2.0-py2.7.egg/dropbox/rest.py", line 254, in POST&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; post_params=params, headers=headers, raw_response=raw_response)&lt;BR /&gt;
&amp;nbsp; File "/Library/Python/2.7/site-packages/dropbox-2.2.0-py2.7.egg/dropbox/rest.py", line 227, in request&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; raise ErrorResponse(r, r.read())&lt;BR /&gt;
dropbox.rest.ErrorResponse: [400] u'invalid_grant'&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Wed, 05 Aug 2015 09:38:00 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Python-error-when-setting-up-access-for-my-App-to-Dropbox/m-p/24802#M732</guid>
      <dc:creator>Mobistudios A.</dc:creator>
      <dc:date>2015-08-05T09:38:00Z</dc:date>
    </item>
    <item>
      <title>Re: Python error when setting up access for my App to Dropbox account</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Python-error-when-setting-up-access-for-my-App-to-Dropbox/m-p/24803#M733</link>
      <description>&lt;P&gt;Are you sure you're entering the access code from dropbox.com properly?&amp;nbsp;Also make sure you're only using the code you get once.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Aug 2015 09:40:41 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Python-error-when-setting-up-access-for-my-App-to-Dropbox/m-p/24803#M733</guid>
      <dc:creator>Steve M.</dc:creator>
      <dc:date>2015-08-05T09:40:41Z</dc:date>
    </item>
    <item>
      <title>Re: Python error when setting up access for my App to Dropbox account</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Python-error-when-setting-up-access-for-my-App-to-Dropbox/m-p/24804#M734</link>
      <description>&lt;P&gt;"Are you sure you're entering the access code from dropbox.com properly"&lt;/P&gt;

&lt;P&gt;Yes, I'm using a new access token.&lt;/P&gt;

&lt;P&gt;1.&lt;/P&gt;

&lt;P&gt;I go to my App console on Dropbox Developers&lt;/P&gt;

&lt;P&gt;2.&lt;/P&gt;

&lt;P&gt;I open up my app&lt;/P&gt;

&lt;P&gt;3.&lt;/P&gt;

&lt;P&gt;Then go to Generated access token.&lt;/P&gt;

&lt;P&gt;4.&lt;/P&gt;

&lt;P&gt;I use that token when it prompts me.&lt;/P&gt;

&lt;P&gt;5.&lt;/P&gt;

&lt;P&gt;I'm using the terminal on a Mac 10.11.4.&lt;/P&gt;

&lt;P&gt;Just upgraded python from 2.7.6 to 2.7.9 and still incurring the same error message.&lt;/P&gt;

&lt;H1&gt;Error Message&lt;/H1&gt;

&lt;P&gt;W8006005A54:python ninekay$ python upload.py  &lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;&lt;P&gt;Go to: &lt;A href="https://www.dropbox.com/1/oauth2/authorize?response_type=code&amp;amp;client_id=qdrn1l679o14y86" rel="nofollow noreferrer"&gt;https://www.dropbox.com/1/oauth2/authorize?response_type=code&amp;amp;client_id=qdrn1l679o14y86&lt;/A&gt;  &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;Click "Allow" (you might have to log in first)  &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;Copy the authorization code.  &lt;/P&gt;&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;Enter the authorization code here:&amp;nbsp;&amp;lt;REDACTED&amp;gt;  &lt;/P&gt;

&lt;P&gt;Traceback (most recent call last):  &lt;/P&gt;

&lt;P&gt;&amp;nbsp; File "upload.py", line 21, in &amp;lt;module&amp;gt;  &lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; access_token, user_id = flow.finish(code)  &lt;/P&gt;

&lt;P&gt;&amp;nbsp; File "/Library/Python/2.7/site-packages/dropbox-2.2.0-py2.7.egg/dropbox/client.py", line 1398, in finish  &lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return self._finish(code, None)  &lt;/P&gt;

&lt;P&gt;&amp;nbsp; File "/Library/Python/2.7/site-packages/dropbox-2.2.0-py2.7.egg/dropbox/client.py", line 1265, in _finish  &lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; response = self.rest_client.POST(url, params=params)  &lt;/P&gt;

&lt;P&gt;&amp;nbsp; File "/Library/Python/2.7/site-packages/dropbox-2.2.0-py2.7.egg/dropbox/rest.py", line 316, in POST  &lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return cls.IMPL.POST(*n, **kw)  &lt;/P&gt;

&lt;P&gt;&amp;nbsp; File "/Library/Python/2.7/site-packages/dropbox-2.2.0-py2.7.egg/dropbox/rest.py", line 254, in POST  &lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; post_params=params, headers=headers, raw_response=raw_response)  &lt;/P&gt;

&lt;P&gt;&amp;nbsp; File "/Library/Python/2.7/site-packages/dropbox-2.2.0-py2.7.egg/dropbox/rest.py", line 227, in request  &lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; raise ErrorResponse(r, r.read())  &lt;/P&gt;

&lt;P&gt;dropbox.rest.ErrorResponse: [400] u'invalid_grant'&lt;/P&gt;</description>
      <pubDate>Wed, 05 Aug 2015 10:13:22 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Python-error-when-setting-up-access-for-my-App-to-Dropbox/m-p/24804#M734</guid>
      <dc:creator>Mobistudios A.</dc:creator>
      <dc:date>2015-08-05T10:13:22Z</dc:date>
    </item>
    <item>
      <title>Re: Python error when setting up access for my App to Dropbox account</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Python-error-when-setting-up-access-for-my-App-to-Dropbox/m-p/24805#M735</link>
      <description>&lt;P&gt;You're not supposed to use your generated access token there. As the app says, you should go to the URL it gives you and authorize the app. You'll then receive an access code (not access token) that you need to copy/paste back into the app.&lt;/P&gt;

&lt;P&gt;BTW, I've redacted your access token, but you should probably unlink your app (from dropbox.com/account/security) now that your access token has been published here. With an access token, someone can&amp;nbsp;read and write files in your account, so you never want to share an access token with anyone.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Aug 2015 10:30:57 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Python-error-when-setting-up-access-for-my-App-to-Dropbox/m-p/24805#M735</guid>
      <dc:creator>Steve M.</dc:creator>
      <dc:date>2015-08-05T10:30:57Z</dc:date>
    </item>
    <item>
      <title>Re: Python error when setting up access for my App to Dropbox account</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Python-error-when-setting-up-access-for-my-App-to-Dropbox/m-p/24806#M736</link>
      <description>&lt;P&gt;Steve,&lt;/P&gt;

&lt;P&gt;Now have access. thanks a million for your help.&lt;/P&gt;

&lt;P&gt;When running in the terminal it never displayed that message about going to the other URL.&lt;/P&gt;

&lt;P&gt;So I ran it in my text editor and it showed up. Its the first time I used it.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Aug 2015 10:48:30 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Python-error-when-setting-up-access-for-my-App-to-Dropbox/m-p/24806#M736</guid>
      <dc:creator>Mobistudios A.</dc:creator>
      <dc:date>2015-08-05T10:48:30Z</dc:date>
    </item>
  </channel>
</rss>

