public static function DrupalOAuthToken::loadByKey in OAuth 1.0 7.4
Same name and namespace in other branches
- 6.3 includes/DrupalOAuthToken.inc \DrupalOAuthToken::loadByKey()
- 7.3 includes/DrupalOAuthToken.inc \DrupalOAuthToken::loadByKey()
Gets the token with the specified key
Parameters
string $key: The key of the token to get
boolean|object $consumer: The consumer for which to fetch a token or FALSE to fetch a provider token
int $type: Used internally for backwards compatibility with ::load()
Return value
DrupalOAuthToken The loaded token object or FALSE if load failed
6 calls to DrupalOAuthToken::loadByKey()
- DrupalOAuthClient::getAccessToken in includes/
DrupalOAuthClient.inc - Fetches the access token using the request token.
- DrupalOAuthDataStore::lookup_token in includes/
DrupalOAuthDataStore.inc - Check if the token exists.
- DrupalOAuthToken::load in includes/
DrupalOAuthToken.inc - Deprecated - Gets the token with the specified key
- oauth_common_context_from_request in ./
oauth_common.module - Loads the context for a request.
- oauth_common_form_authorize in ./
oauth_common.pages.inc - Form for granting access to the consumer
File
- includes/
DrupalOAuthToken.inc, line 163
Class
Code
public static function loadByKey($key, $consumer = FALSE, $type = OAUTH_COMMON_TOKEN_TYPE_ACCESS) {
$query = db_select('oauth_common_token', 't');
$query
->condition('t.key_hash', sha1($key))
->fields('t');
// Only add if defined - needed for backwards compatibility with deprecated DrupalOAuthToken::load() from 6.x-3.0-beta3
if ($type !== FALSE) {
$query
->condition('t.type', $type);
}
if (!$consumer || is_object($consumer) && $consumer->provider_consumer) {
$query
->join('oauth_common_provider_token', 'pt', 'pt.tid = t.tid');
$query
->fields('pt', array(
'created',
'changed',
'services',
'authorized',
));
}
// Only fetch non-provider tokens - needed for backwards compatibility with deprecated DrupalOAuthToken::load() from 6.x-3.0-beta3
if ($consumer === TRUE) {
$query
->leftJoin('oauth_common_provider_token', 'pt', 'pt.tid = t.tid');
$query
->isNull('pt.tid');
}
else {
if ($consumer) {
$query
->condition('t.csid', $consumer->csid);
}
}
return self::fromResult($query
->execute(), $consumer);
}