You are here

function oauth2_server_tokens_page in OAuth2 Server 7

Page callback: Returns information about the provided token.

Parameters

$token: The token to verify.

Return value

404 if the token was not found or has expired. Otherwise, if a valid token was found, a json encoded array with the keys:

  • client_id: The client ID who issued the token.
  • user_id: The username of the resource owner, or NULL if not known.
  • access_token: The access token.
  • expires: The unix timestamp of token expiration.
  • scope: Scopes in a space-separated string.
1 string reference to 'oauth2_server_tokens_page'
oauth2_server_menu in ./oauth2_server.module
Implements hook_menu().

File

./oauth2_server.pages.inc, line 198
Page callbacks for the OAuth2 Server module.

Code

function oauth2_server_tokens_page($token) {
  drupal_page_is_cacheable(FALSE);

  // Initialize the storage and try to load the requested token.
  $storage = new Drupal\oauth2_server\Storage();
  $token = $storage
    ->getAccessToken($token);

  // No token found. Stop here.
  if (!$token || $token['expires'] <= time()) {
    $response = new OAuth2\Response(array(), 404);
    return oauth2_server_send_response($response);
  }

  // Return the token, without the server and client_id keys.
  unset($token['server']);
  return drupal_json_output($token);
}