DropBox SDK failing due to "invalid_access_token"

893 Views Asked by At

I'm using the Dropbox.API Nuget (latest version 6.26.0) for my C#.net desktop application. I'm obtaining a DropBox access token by requesting authorization using my client_id:

var requestUrl = $"https://www.dropbox.com/oauth2/authorize?client_id={_appKey}&response_type=code";

I am invoking this without a redirect_url, therefore it presents me a webpage with the access token. This is the access token i am using for other SDK API calls.

The response I get from this includes a URL which allows me to confirm and approve the auth request, which it then presents me with an access token string.

Then i take that access token and use it to initialize the DropboxClient.

var client = new DropboxClient(AccessToken)

Where the AccessToken is indeed the access token string (confirmed).

Now oddly enough, im getting an invalid access token exception when i try to create the DropboxClient instance.

Question: Seems like im missing something thats right under my nose. What am i doing wrong?

Note that there is a thread, https://github.com/dropbox/dropbox-sdk-java/issues/113, but it leads to a deadend.

Also note that I had this working just fine a few days ago. And suddenly now it is not working. I had it working by following this documentation: https://developers.dropbox.com/oauth-guide.

1

There are 1 best solutions below

0
On BEST ANSWER

I found the answer. I blame it on poor documentation by DropBox. Basically, the "access token" that i've been using is actually the "authorization token", which is what i need to use to obtain the actual access token ( via https://api.dropboxapi.com/oauth2/token ).

Solution that worked for me:

  1. Make a call to https://www.dropbox.com/oauth2/authorize.
  2. Open URL provided by the response from step 1.
  3. Copy the AUTH TOKEN provided by the URL from step 2.
  4. Obtain the ACCESS TOKEN by making a call to https://api.dropboxapi.com/oauth2/token using the AUTH TOKEN copied from step 3.
  5. Make a call to a DropBox API using the DropBox SDK and pass in the ACCESS TOKEN obtained from step 4.