You are here

function oauth_common_context_from_request in OAuth 1.0 6.3

Same name and namespace in other branches
  1. 7.4 oauth_common.module \oauth_common_context_from_request()
  2. 7.3 oauth_common.module \oauth_common_context_from_request()

Loads the context for a request.

Parameters

OAuthRequest $request:

Return value

object The context configuration.

3 calls to oauth_common_context_from_request()
oauth_common_callback_access_token in ./oauth_common.pages.inc
Get a access token for the request
oauth_common_callback_request_token in ./oauth_common.pages.inc
Generate a request token from the request.
oauth_common_form_authorize in ./oauth_common.pages.inc
Form for granting access to the consumer

File

./oauth_common.module, line 476

Code

function oauth_common_context_from_request($request) {
  $context = NULL;
  $consumer_key = $request
    ->get_parameter('oauth_consumer_key');
  $token_key = $request
    ->get_parameter('oauth_token');
  if (empty($consumer_key) && !empty($token_key)) {
    $token = DrupalOAuthToken::loadByKey($token_key, FALSE, OAUTH_COMMON_TOKEN_TYPE_REQUEST);
    if ($token) {
      $consumer = $token->consumer;
    }
  }
  if (!empty($consumer_key)) {
    $consumer = DrupalOAuthConsumer::loadProviderByKey($consumer_key);
  }
  if (!empty($consumer)) {
    $context = oauth_common_context_load($consumer->context);
  }
  return $context;
}