Showing results for 
Show  only  | Search instead for 
Did you mean: 
We're looking to hear about your experience when using Dropbox in a web browser. What parts of Dropbox feels very slow to you and takes a lot of time to get done? What are you trying to do in the Dropbox web browser when you experience slowness? Tell us right here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

Showing results for 
Show  only  | Search instead for 
Did you mean: 
Reply and help

DropBox API: uploading a file issue

DropBox API: uploading a file issue

Explorer | Level 3


          I first get the token from:



          I use the following method:


using (var dbx = new DropboxClient(token))

I call the following method:

async Task Upload(DropboxClient dbx, string folder, string file, string content)
using (var mem = new MemoryStream(Encoding.UTF8.GetBytes(content)))
         var updated = await dbx.Files.UploadAsync(
          "/" + file,
          body: mem);


I get the following error when trying to upload (dbx.Files.UploadAsync) : Dropbox.Api.AuthException: invalid_access_token


I use the token right after accessing the oauth2 page with credentials and it returns a token.


Could you please advise as what is the problem with the invalid token error?


Thank you

1 Reply 1

Re: DropBox API: uploading a file issue


In your /oauth2/authorize 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 /oauth2/token. The /oauth2/token 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 the OAuth Guide, as well as the authorization documentation


And if you're using the official Dropbox .NET SDK anyway, you should use the OAuth helpers it provides, as that will do much of the work for you. The documentation includes examples of how to use those in different contexts, resulting in an access token. There's also a sample web app that implements the OAuth flow as an example.


Also, note that per the documentation, the app authorization page should be accessed at , not on as you have in your post.

Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropboxer
What do Dropbox user levels mean?
Need more support?