<?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 The given OAuth 2 access token is malformed. in Discuss Dropbox Developer &amp; API</title>
    <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/The-given-OAuth-2-access-token-is-malformed/m-p/566414#M2305</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Previously, I had saved the OAuth 2 access token in a variable in my Python code, and I was able to use the token to connect and download files from my Dropbox folders. However, I decided to store the OAuth 2 access token in a local file on my drive instead, so in case (for some inexplicable reason) if it changed in the future, I wouldn't have to make any code change. Unfortunately, under this scenario I get the following error when I try to download files:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;File "C:\Users\lib\site-packages\dropbox\base.py", line 1310, in files_download_to_file&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;r = self.request(&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;File "C:\Users\hrh74\lib\site-packages\dropbox\dropbox_client.py", line 323, in request&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;res = self.request_json_string_with_retry(host,&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;File "C:\Users\lib\site-packages\dropbox\dropbox_client.py", line 479, in request_json_string_with_retry&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;return self.request_json_string(host,&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;File "C:\Users\lib\site-packages\dropbox\dropbox_client.py", line 604, in request_json_string&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;raise BadInputError(request_id, r.text)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;dropbox.exceptions.BadInputError: BadInputError('5a7e90464ddc473e925b048f9a99fc08', 'Error in call to API function "files/download": The given OAuth 2 access token is malformed.')&lt;/STRONG&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The file that has the OAuth 2 token is a simple text file with one line with the token as follow:&lt;/P&gt;
&lt;P&gt;"xyz........"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any insight as why the token within the code works but retrieving it from a local text file doesn't?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
    <pubDate>Fri, 14 Jan 2022 20:27:00 GMT</pubDate>
    <dc:creator>hrh747</dc:creator>
    <dc:date>2022-01-14T20:27:00Z</dc:date>
    <item>
      <title>The given OAuth 2 access token is malformed.</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/The-given-OAuth-2-access-token-is-malformed/m-p/566414#M2305</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Previously, I had saved the OAuth 2 access token in a variable in my Python code, and I was able to use the token to connect and download files from my Dropbox folders. However, I decided to store the OAuth 2 access token in a local file on my drive instead, so in case (for some inexplicable reason) if it changed in the future, I wouldn't have to make any code change. Unfortunately, under this scenario I get the following error when I try to download files:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;File "C:\Users\lib\site-packages\dropbox\base.py", line 1310, in files_download_to_file&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;r = self.request(&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;File "C:\Users\hrh74\lib\site-packages\dropbox\dropbox_client.py", line 323, in request&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;res = self.request_json_string_with_retry(host,&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;File "C:\Users\lib\site-packages\dropbox\dropbox_client.py", line 479, in request_json_string_with_retry&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;return self.request_json_string(host,&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;File "C:\Users\lib\site-packages\dropbox\dropbox_client.py", line 604, in request_json_string&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;raise BadInputError(request_id, r.text)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;dropbox.exceptions.BadInputError: BadInputError('5a7e90464ddc473e925b048f9a99fc08', 'Error in call to API function "files/download": The given OAuth 2 access token is malformed.')&lt;/STRONG&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The file that has the OAuth 2 token is a simple text file with one line with the token as follow:&lt;/P&gt;
&lt;P&gt;"xyz........"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any insight as why the token within the code works but retrieving it from a local text file doesn't?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jan 2022 20:27:00 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/The-given-OAuth-2-access-token-is-malformed/m-p/566414#M2305</guid>
      <dc:creator>hrh747</dc:creator>
      <dc:date>2022-01-14T20:27:00Z</dc:date>
    </item>
    <item>
      <title>Re: The given OAuth 2 access token is malformed.</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/The-given-OAuth-2-access-token-is-malformed/m-p/566487#M2306</link>
      <description>&lt;P&gt;Hi &lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1482882"&gt;@hrh747&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Since you have your access token checked and it's working, seems you have saved the token in wrong way and/or improperly read it within your code. The best way for debug this case, I think, is to "resurrect" the variable you did use before, so there would be reference value. Compare value you are reading from file to the reference one. Does they match? &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; If need, compare the values symbol by symbol to find out where precisely the difference is. &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, have you stripped blanks on read?&lt;/P&gt;&lt;P&gt;Hope this gives right direction.&lt;/P&gt;</description>
      <pubDate>Sun, 26 Dec 2021 21:48:29 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/The-given-OAuth-2-access-token-is-malformed/m-p/566487#M2306</guid>
      <dc:creator>Здравко</dc:creator>
      <dc:date>2021-12-26T21:48:29Z</dc:date>
    </item>
    <item>
      <title>Re: The given OAuth 2 access token is malformed.</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/The-given-OAuth-2-access-token-is-malformed/m-p/566640#M2309</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the kind response. Yes, I have stripped the blank while reading the token, however, I am to take your advice and make the string comparison to see where the difference might be. I will let you know.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Dec 2021 15:22:40 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/The-given-OAuth-2-access-token-is-malformed/m-p/566640#M2309</guid>
      <dc:creator>hrh747</dc:creator>
      <dc:date>2021-12-27T15:22:40Z</dc:date>
    </item>
    <item>
      <title>Re: The given OAuth 2 access token is malformed.</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/The-given-OAuth-2-access-token-is-malformed/m-p/566647#M2310</link>
      <description>&lt;P&gt;Thanks for the tip. The string comparison revealed an interesting fact. A pair of double quotes surrounded the token in the external file. It turned out that Python wrapped the token with additional pair of single quotes when reading it from the external file. I saved the token in the file without the double-quotes, and the code is working now &lt;img class="lia-deferred-image lia-image-emoji" src="https://www.dropboxforum.com/html/@FBF7D2AB59A0D6E861EBF6A36F93B7E2/emoticons/1f642.png" alt=":slightly_smiling_face:" title=":slightly_smiling_face:" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I thank you immensely for the help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Dec 2021 15:44:05 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/The-given-OAuth-2-access-token-is-malformed/m-p/566647#M2310</guid>
      <dc:creator>hrh747</dc:creator>
      <dc:date>2021-12-27T15:44:05Z</dc:date>
    </item>
  </channel>
</rss>

