public function Client::revokeToken in OAuth2 Client 7.2
Revokes an access token on the server.
Return value
bool Returns TRUE if the revocation was successful, otherwise FALSE.
File
- src/
Client.php, line 487 - Class OAuth2\Client.
Class
- Client
- The class OAuth2\Client is used to communicate with an oauth2 server.
Namespace
OAuth2Code
public function revokeToken() {
$data = array(
'token' => $this->token['access_token'],
);
$client_id = $this->params['client_id'];
$client_secret = $this->params['client_secret'];
$revoke_endpoint = $this->params['revoke_endpoint'];
$options = array(
'method' => 'POST',
'data' => drupal_http_build_query($data),
'headers' => array(
'Content-Type' => 'application/x-www-form-urlencoded',
'Authorization' => 'Basic ' . base64_encode("{$client_id}:{$client_secret}"),
),
);
if ($this->params['skip-ssl-verification']) {
$options['context'] = stream_context_create(array(
'ssl' => array(
'verify_peer' => FALSE,
'verify_peer_name' => FALSE,
),
));
}
$result = drupal_http_request($revoke_endpoint, $options);
$this
->clearToken();
return $result->code == 200;
}