Skip to content

Getting exception when revoking access token #21

@cetteup

Description

@cetteup

Hi,

I'm using the code below to revoke access tokens, but I always get a Dropbox\Exceptions\DropboxClientException with message 'Invalid Response' (thus the if-statement in the catch).

try {
  $app = new Dropbox\DropboxApp($dropbox_app_id,$dropbox_app_sec,$user_access_token);
  $dropbox = new Dropbox\Dropbox($app);
  $authHelper = $dropbox->getAuthHelper();
  $authHelper->revokeAccessToken();
} catch (Dropbox\Exceptions\DropboxClientException $e) {
  if ($e->getMessage() == 'Invalid Response') {
      echo 'Token revoked';
  }
}

The revoke works fine, I was just wondering whether there is a way to revoke the token without getting the exception. Here is what I found:
The exception gets thrown as the response is validated. According to the official documentation revoking a token does not return anything. Since the validate function is built to throw the exception if the decodedBody of the response is null, the exception will always get thrown when revoking a token.

So, we'd need to pass something like a $isRevokeRequest parameter to the validateResponse function in order to not get the exception.

Cheers,
-Taduuda

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions