<?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 3.7 API upload error in Discuss Dropbox Developer &amp; API</title>
    <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Python-3-7-API-upload-error/m-p/382809#M908</link>
    <description>&lt;P&gt;Basically, I am having a similar problem to what a user named delta was having at the thread located via&amp;nbsp;&lt;A href="https://www.dropboxforum.com/t5/Discuss-Developer-API/Python-3-5-API-upload-error/m-p/317699#M345.%C2%A0" target="_blank" rel="noopener"&gt;https://www.dropboxforum.com/t5/Discuss-Developer-API/Python-3-5-API-upload-error/m-p/317699#M345.%C2%A0&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;We are using the same code, but instead of an UploadWriteFailed, I am receiving,&lt;/P&gt;
&lt;PRE&gt;Traceback (most recent call last):
  File "pi_surveillance.py", line 125, in &amp;lt;module&amp;gt;
    client.files_upload(open(t.path, "rb").read(), path)
  File "/home/pi/.virtualenvs/cv/lib/python3.7/site-packages/dropbox/base.py", line 2458, in files_upload
    f,
  File "/home/pi/.virtualenvs/cv/lib/python3.7/site-packages/dropbox/dropbox.py", line 274, in request
    timeout=timeout)
  File "/home/pi/.virtualenvs/cv/lib/python3.7/site-packages/dropbox/dropbox.py", line 365, in request_json_string_with_retry
    timeout=timeout)
  File "/home/pi/.virtualenvs/cv/lib/python3.7/site-packages/dropbox/dropbox.py", line 456, in request_json_string
    raise BadInputError(request_id, r.text)
dropbox.exceptions.BadInputError: BadInputError('5357e21e05231ec14ee350a296cced7b', 'Error in call to API function "files/upload": The given OAuth 2 access token is malformed.')&lt;/PRE&gt;
&lt;P&gt;Basically giving me the error that the auth token is malformed.&lt;/P&gt;
&lt;PRE&gt;	"use_dropbox": true,
	"dropbox_access_token": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
	"dropbox_base_path": "/security",&lt;/PRE&gt;
&lt;P&gt;This is the config file that verifies dropbox, and the error is happening here.&lt;/P&gt;
&lt;PRE&gt;		print("[UPLOAD] {}".format(ts))
					path = "/{base_path}/{timestamp}.jpg".format(
					    base_path=conf["dropbox_base_path"], timestamp=ts)
					client.files_upload(open(t.path, "rb").read(), path)
					t.cleanup()&lt;/PRE&gt;
&lt;P&gt;I could definitely use some assistance with this if anyone can, thank you!&lt;/P&gt;</description>
    <pubDate>Fri, 06 Dec 2019 23:46:20 GMT</pubDate>
    <dc:creator>Dextral</dc:creator>
    <dc:date>2019-12-06T23:46:20Z</dc:date>
    <item>
      <title>Python 3.7 API upload error</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Python-3-7-API-upload-error/m-p/382809#M908</link>
      <description>&lt;P&gt;Basically, I am having a similar problem to what a user named delta was having at the thread located via&amp;nbsp;&lt;A href="https://www.dropboxforum.com/t5/Discuss-Developer-API/Python-3-5-API-upload-error/m-p/317699#M345.%C2%A0" target="_blank" rel="noopener"&gt;https://www.dropboxforum.com/t5/Discuss-Developer-API/Python-3-5-API-upload-error/m-p/317699#M345.%C2%A0&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;We are using the same code, but instead of an UploadWriteFailed, I am receiving,&lt;/P&gt;
&lt;PRE&gt;Traceback (most recent call last):
  File "pi_surveillance.py", line 125, in &amp;lt;module&amp;gt;
    client.files_upload(open(t.path, "rb").read(), path)
  File "/home/pi/.virtualenvs/cv/lib/python3.7/site-packages/dropbox/base.py", line 2458, in files_upload
    f,
  File "/home/pi/.virtualenvs/cv/lib/python3.7/site-packages/dropbox/dropbox.py", line 274, in request
    timeout=timeout)
  File "/home/pi/.virtualenvs/cv/lib/python3.7/site-packages/dropbox/dropbox.py", line 365, in request_json_string_with_retry
    timeout=timeout)
  File "/home/pi/.virtualenvs/cv/lib/python3.7/site-packages/dropbox/dropbox.py", line 456, in request_json_string
    raise BadInputError(request_id, r.text)
dropbox.exceptions.BadInputError: BadInputError('5357e21e05231ec14ee350a296cced7b', 'Error in call to API function "files/upload": The given OAuth 2 access token is malformed.')&lt;/PRE&gt;
&lt;P&gt;Basically giving me the error that the auth token is malformed.&lt;/P&gt;
&lt;PRE&gt;	"use_dropbox": true,
	"dropbox_access_token": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
	"dropbox_base_path": "/security",&lt;/PRE&gt;
&lt;P&gt;This is the config file that verifies dropbox, and the error is happening here.&lt;/P&gt;
&lt;PRE&gt;		print("[UPLOAD] {}".format(ts))
					path = "/{base_path}/{timestamp}.jpg".format(
					    base_path=conf["dropbox_base_path"], timestamp=ts)
					client.files_upload(open(t.path, "rb").read(), path)
					t.cleanup()&lt;/PRE&gt;
&lt;P&gt;I could definitely use some assistance with this if anyone can, thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 06 Dec 2019 23:46:20 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Python-3-7-API-upload-error/m-p/382809#M908</guid>
      <dc:creator>Dextral</dc:creator>
      <dc:date>2019-12-06T23:46:20Z</dc:date>
    </item>
    <item>
      <title>Re: Python 3.7 API upload error</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Python-3-7-API-upload-error/m-p/383157#M909</link>
      <description>&lt;P&gt;This error message indicates that the access token you're using isn't of the expected format. You appear to be storing your access token in that "dropbox_access_token" field. To be clear though, you've redacted it for this forum post, correct? (If not, note that attempting to just uses the 'x's will fail. You need to replace it with &lt;A href="https://www.dropbox.com/developers/reference/oauth-guide" target="_self"&gt;an actual access token from Dropbox&lt;/A&gt;.)&lt;/P&gt;
&lt;P&gt;Can you double check that the access token string you have saved there is the exact value you&amp;nbsp;received from&amp;nbsp;Dropbox when initially retrieving the access token? It will generally be a 64 character string of letters, numbers, and - or _.&amp;nbsp; Make sure there aren't any extra characters accidentally added on, for instance.&lt;/P&gt;
&lt;P&gt;Also, how are you loading that string into the&amp;nbsp;Dropbox 'client' object? Please make sure it isn't accidentally getting modified somewhere along the way.&lt;/P&gt;
&lt;P&gt;Another thing you can do is to add some extra logging of the network call, so you can inspect what is actually getting sent:&lt;/P&gt;
&lt;PRE&gt;import http.client as http_client
http_client.HTTPConnection.debuglevel = 1&lt;/PRE&gt;
&lt;P&gt;(Make sure you don't post your access token here.)&lt;/P&gt;</description>
      <pubDate>Mon, 09 Dec 2019 16:59:54 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Python-3-7-API-upload-error/m-p/383157#M909</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2019-12-09T16:59:54Z</dc:date>
    </item>
  </channel>
</rss>

