You are here

function _oauth_common_validate_request_callback in OAuth 1.0 6.3

Same name and namespace in other branches
  1. 7.4 oauth_common.pages.inc \_oauth_common_validate_request_callback()
  2. 7.3 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
Implementation of hook_menu().

File

./oauth_common.pages.inc, line 6

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_set_header('HTTP/1.0 401 Unauthorized: ' . $e
      ->getMessage());
    drupal_set_header(sprintf('WWW-Authenticate: OAuth realm="%s"', url('', array(
      'absolute' => TRUE,
    ))));
  }
  exit;
}