cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Revoke access token

Revoke access token

Anil
Explorer | Level 4
Go to solution

Hi,

 

I am trying to revoke the token when we trying to logoff the dropbox from my android app.

it always showing some error.

 

eg:

https://api.dropboxapi.com/2/auth/token/revoke
and set the header as "Authorization: Bearer <access token>"

 

it would be fine, if you provide the correct url and how to use it android.

 

Anil.S

 

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

You don't need to use DbxRawClientV2. You can use tokenRevoke on DbxClientV2 like this:

 

DbxClientV2 client = new DbxClientV2(config, ACCESS_TOKEN);

// note: be sure to add error handling
client.auth().tokenRevoke();

And if you're using the SDK, you don't need to construct the authorization URL yourself. There's an Android example here that shows how to process the flow in the SDK:

 

https://github.com/dropbox/dropbox-sdk-java/tree/master/examples/android

 

Specifically, you start the flow using startOAuth2Authentication:

 

https://github.com/dropbox/dropbox-sdk-java/blob/master/examples/android/src/main/java/com/dropbox/c...

 

And finish it in onResume:

 

https://github.com/dropbox/dropbox-sdk-java/blob/master/examples/android/src/main/java/com/dropbox/c...

View solution in original post

4 Replies 4

Greg-DB
Dropbox Staff
Go to solution

What error are you getting?

There's an example of calling that endpoint via curl here in the documentation:

https://www.dropbox.com/developers/documentation/http/documentation#auth-token-revoke

By the way, if you're building an Android app, we recommend using the official Java SDK:

https://www.dropbox.com/developers/documentation/java

In the Java SDK, you would use the tokenRevoke method to revoke a token:

https://dropbox.github.io/dropbox-sdk-java/api-docs/v2.1.x/com/dropbox/core/v2/auth/DbxUserAuthReque...

Anil
Explorer | Level 4
Go to solution

Thanks Greg.

 

I used 'DbxClientV2' for getting files and folder list.
Never used the 'DbxRawClientV2' in my application and it seems DbxUserAuthRequests expecting 'DbxRawClientV2'  object as parameter.

 

For authentication, i used android native webview control and used the following url.
For eg: https://www.dropbox.com/oauth2/authorize/?client_id=<clientID>&response_type=code&redirect_uri=<redi...>

And it gives the Accestoken and then set it to the 'DbxClientV2' for listing files.

How can i use the 'DbxUserAuthRequests', please help.

 

Anil.S

Greg-DB
Dropbox Staff
Go to solution

You don't need to use DbxRawClientV2. You can use tokenRevoke on DbxClientV2 like this:

 

DbxClientV2 client = new DbxClientV2(config, ACCESS_TOKEN);

// note: be sure to add error handling
client.auth().tokenRevoke();

And if you're using the SDK, you don't need to construct the authorization URL yourself. There's an Android example here that shows how to process the flow in the SDK:

 

https://github.com/dropbox/dropbox-sdk-java/tree/master/examples/android

 

Specifically, you start the flow using startOAuth2Authentication:

 

https://github.com/dropbox/dropbox-sdk-java/blob/master/examples/android/src/main/java/com/dropbox/c...

 

And finish it in onResume:

 

https://github.com/dropbox/dropbox-sdk-java/blob/master/examples/android/src/main/java/com/dropbox/c...

Anil
Explorer | Level 4
Go to solution

Thanks Greg for your great help.


@Greg-DB wrote:

You don't need to use DbxRawClientV2. You can use tokenRevoke on DbxClientV2 like this:

 

DbxClientV2 client = new DbxClientV2(config, ACCESS_TOKEN);

// note: be sure to add error handling
client.auth().tokenRevoke();

And if you're using the SDK, you don't need to construct the authorization URL yourself. There's an Android example here that shows how to process the flow in the SDK:

 

https://github.com/dropbox/dropbox-sdk-java/tree/master/examples/android

 

Specifically, you start the flow using startOAuth2Authentication:

 

https://github.com/dropbox/dropbox-sdk-java/blob/master/examples/android/src/main/java/com/dropbox/c...

 

And finish it in onResume:

 

https://github.com/dropbox/dropbox-sdk-java/blob/master/examples/android/src/main/java/com/dropbox/c...


 

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Anil Explorer | Level 4
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?