You are here

function hook_oauth2_server_token in OAuth2 Server 7

Execute operations before OAuth2 Server sends a token response.

Parameters

\OAuth2Server|NULL $server:

\OAuth2\Request $request:

\OAuth2\Response $response:

1 invocation of hook_oauth2_server_token()
oauth2_server_token_page in ./oauth2_server.pages.inc
Page callback: exchanges an authorization code for an access token.

File

./oauth2_server.api.php, line 32
Hooks provided by the OAuth2 Server module.

Code

function hook_oauth2_server_token($server, \OAuth2\Request $request, \OAuth2\Response $response) {

  // Example: if the response is not successful, log a message.
  if ($response
    ->getStatusCode() != 200) {
    watchdog('mymodule', 'Failed token response from server @server: @code @body', array(
      '@server' => $server ? $server->name : NULL,
      '@code' => $response
        ->getStatusCode(),
      '@body' => $response
        ->getResponseBody(),
    ));
  }
}