<?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 DropBox API: uploading a file issue in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/DropBox-API-uploading-a-file-issue/m-p/430518#M22825</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; I first get the token from:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://api.dropbox.com/1/oauth2/authorize?response_type=code&amp;amp;client_id=xxxxxxxxxxx&amp;amp;redirect_uri=https://localhost:44332/Test" target="_blank" rel="noopener"&gt;https://api.dropbox.com/1/oauth2/authorize?response_type=code&amp;amp;client_id=xxxxxxxxxxx&amp;amp;redirect_uri=https://localhost:44332/Test&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; following&amp;nbsp;&lt;A title="https://www.dropbox.com/developers/documentation/dotnet#tutorial" href="https://www.dropbox.com/developers/documentation/dotnet#tutorial" target="_blank" rel="noopener"&gt;https://www.dropbox.com/developers/documentation/dotnet#tutorial&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; I use the following method:&amp;nbsp;&lt;A href="https://dropbox.github.io/dropbox-sdk-dotnet/html/M_Dropbox_Api_Files_Routes_FilesUserRoutes_UploadAsync_1.htm" target="_blank" rel="noopener"&gt;https://dropbox.github.io/dropbox-sdk-dotnet/html/M_Dropbox_Api_Files_Routes_FilesUserRoutes_UploadAsync_1.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;using (var dbx = new DropboxClient(token))&lt;/P&gt;&lt;P&gt;I call the following method:&lt;/P&gt;&lt;P&gt;async Task Upload(DropboxClient dbx, string folder, string file, string content)&lt;BR /&gt;{&lt;BR /&gt;using (var mem = new MemoryStream(Encoding.UTF8.GetBytes(content)))&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var updated = await dbx.Files.UploadAsync(&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; "/" + file,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WriteMode.Overwrite.Instance,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; body: mem);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;I get the following error when trying to upload (dbx.Files.UploadAsync) :&amp;nbsp;Dropbox.Api.AuthException: invalid_access_token&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I use the token right after accessing the oauth2 page with credentials and it returns a token.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please advise as what is the problem with the invalid token error?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
    <pubDate>Wed, 17 Jun 2020 16:17:36 GMT</pubDate>
    <dc:creator>IQCloud</dc:creator>
    <dc:date>2020-06-17T16:17:36Z</dc:date>
    <item>
      <title>DropBox API: uploading a file issue</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/DropBox-API-uploading-a-file-issue/m-p/430518#M22825</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; I first get the token from:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://api.dropbox.com/1/oauth2/authorize?response_type=code&amp;amp;client_id=xxxxxxxxxxx&amp;amp;redirect_uri=https://localhost:44332/Test" target="_blank" rel="noopener"&gt;https://api.dropbox.com/1/oauth2/authorize?response_type=code&amp;amp;client_id=xxxxxxxxxxx&amp;amp;redirect_uri=https://localhost:44332/Test&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; following&amp;nbsp;&lt;A title="https://www.dropbox.com/developers/documentation/dotnet#tutorial" href="https://www.dropbox.com/developers/documentation/dotnet#tutorial" target="_blank" rel="noopener"&gt;https://www.dropbox.com/developers/documentation/dotnet#tutorial&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; I use the following method:&amp;nbsp;&lt;A href="https://dropbox.github.io/dropbox-sdk-dotnet/html/M_Dropbox_Api_Files_Routes_FilesUserRoutes_UploadAsync_1.htm" target="_blank" rel="noopener"&gt;https://dropbox.github.io/dropbox-sdk-dotnet/html/M_Dropbox_Api_Files_Routes_FilesUserRoutes_UploadAsync_1.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;using (var dbx = new DropboxClient(token))&lt;/P&gt;&lt;P&gt;I call the following method:&lt;/P&gt;&lt;P&gt;async Task Upload(DropboxClient dbx, string folder, string file, string content)&lt;BR /&gt;{&lt;BR /&gt;using (var mem = new MemoryStream(Encoding.UTF8.GetBytes(content)))&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var updated = await dbx.Files.UploadAsync(&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; "/" + file,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WriteMode.Overwrite.Instance,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; body: mem);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;I get the following error when trying to upload (dbx.Files.UploadAsync) :&amp;nbsp;Dropbox.Api.AuthException: invalid_access_token&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I use the token right after accessing the oauth2 page with credentials and it returns a token.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please advise as what is the problem with the invalid token error?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jun 2020 16:17:36 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/DropBox-API-uploading-a-file-issue/m-p/430518#M22825</guid>
      <dc:creator>IQCloud</dc:creator>
      <dc:date>2020-06-17T16:17:36Z</dc:date>
    </item>
    <item>
      <title>Re: DropBox API: uploading a file issue</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/DropBox-API-uploading-a-file-issue/m-p/430588#M22826</link>
      <description>&lt;P&gt;In your &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#oauth2-authorize" target="_self"&gt;/oauth2/authorize&lt;/A&gt; URL, I see that you're using the 'response_type=code' flow, which means you're using the OAuth 2 "code flow". In this flow, the code that you get back from that page is an "authorization code", not an "access token". When using the code flow, you need to then exchange the authorization code for an access token by calling &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#oauth2-token" target="_self"&gt;/oauth2/token&lt;/A&gt;. The&amp;nbsp;&lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#oauth2-token" target="_self"&gt;/oauth2/token&lt;/A&gt;&amp;nbsp;response will contain the access token that you can then use to make actual API calls. (Attempting to use an authorization code in place of an access token to attempt to make actual API calls will result in an 'invalid_access_token' error.) You can find more information on how the OAuth flow works in &lt;A href="https://www.dropbox.com/developers/reference/oauth-guide" target="_self"&gt;the OAuth Guide&lt;/A&gt;, as well as &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#authorization" target="_self"&gt;the authorization documentation&lt;/A&gt;.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And if you're using &lt;A href="https://github.com/dropbox/dropbox-sdk-dotnet" target="_self"&gt;the official Dropbox .NET SDK&lt;/A&gt; anyway, you should use &lt;A href="https://dropbox.github.io/dropbox-sdk-dotnet/html/T_Dropbox_Api_DropboxOAuth2Helper.htm" target="_self"&gt;the OAuth helpers&lt;/A&gt; it provides, as that will do much of the work for you. The &lt;A href="https://dropbox.github.io/dropbox-sdk-dotnet/html/T_Dropbox_Api_DropboxOAuth2Helper.htm" target="_self"&gt;documentation includes examples&lt;/A&gt; of how to use those in different contexts, resulting in an access token. There's also &lt;A href="https://github.com/dropbox/dropbox-sdk-dotnet/tree/master/dropbox-sdk-dotnet/Examples/SimpleBlogDemo" target="_self"&gt;a sample web app&lt;/A&gt; that implements the OAuth flow as an example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, note that per &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#oauth2-authorize" target="_self"&gt;the documentation&lt;/A&gt;, the app authorization page should be accessed at&amp;nbsp;&lt;A href="https://www.dropbox.com/oauth2/authorize" target="_blank"&gt;https://www.dropbox.com/oauth2/authorize&lt;/A&gt; , not on&amp;nbsp;api.dropbox.com as you have in your post.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jun 2020 20:25:11 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/DropBox-API-uploading-a-file-issue/m-p/430588#M22826</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2020-06-17T20:25:11Z</dc:date>
    </item>
  </channel>
</rss>

