You are here

function _oauth_common_validate_request_callback in OAuth 1.0 7.3

Same name and namespace in other branches
  1. 6.3 oauth_common.pages.inc \_oauth_common_validate_request_callback()
  2. 7.4 oauth_common.pages.inc \_oauth_common_validate_request_callback()

Combined menu callback for tests of consumers and access tokens

1 string reference to '_oauth_common_validate_request_callback'
oauth_common_menu in ./oauth_common.module
Implements hook_menu().

File

./oauth_common.pages.inc, line 10
Page callbacks for OAuth module

Code

function _oauth_common_validate_request_callback($type, $unsigned = NULL) {
  try {
    module_load_include('inc', 'oauth_common');
    list($signed, $consumer, $token) = oauth_common_verify_request();
    if ($consumer == NULL) {
      throw new OAuthException('Missing consumer token');
    }
    if (!$signed && $unsigned != 'unsigned') {
      throw new OAuthException("The request wasn't signed");
    }
    if ($token == NULL && $type == 'access token') {
      throw new OAuthException('Missing access token');
    }
  } catch (OAuthException $e) {
    drupal_add_http_header('Status', '401 Unauthorized: ' . $e
      ->getMessage());
    drupal_add_http_header('WWW-Authenticate', sprintf('OAuth realm="%s"', url('', array(
      'absolute' => TRUE,
    ))));
  }
  exit;
}