You are here

public static function DrupalOAuthToken::loadById in OAuth 1.0 7.4

Same name and namespace in other branches
  1. 6.3 includes/DrupalOAuthToken.inc \DrupalOAuthToken::loadById()
  2. 7.3 includes/DrupalOAuthToken.inc \DrupalOAuthToken::loadById()

Gets the token with the specified id

Parameters

int $id: The id of the token to get

boolean $load_provider_data: Whether to load provider related data or not

Return value

DrupalOAuthToken The loaded token object or FALSE if load failed

File

includes/DrupalOAuthToken.inc, line 202

Class

DrupalOAuthToken

Code

public static function loadById($tid, $load_provider_data = TRUE) {
  $query = db_select('oauth_common_token', 't');
  $query
    ->condition('t.tid', $tid)
    ->fields('t');
  if ($load_provider_data) {
    $query
      ->join('oauth_common_provider_token', 'pt', 'pt.tid = t.tid');
    $query
      ->fields('pt', array(
      'created',
      'changed',
      'services',
      'authorized',
    ));
  }
  return self::fromResult($query
    ->execute());
}