function oauth_common_page_authorized in OAuth 1.0 6.3
Same name and namespace in other branches
- 7.4 oauth_common.pages.inc \oauth_common_page_authorized()
- 7.3 oauth_common.pages.inc \oauth_common_page_authorized()
Menu callback for when something has been authorized - used in both client and provider flow
Parameters
$csid Should contain the id of the consumer when used in the client flow:
1 string reference to 'oauth_common_page_authorized'
- oauth_common_menu in ./
oauth_common.module - Implementation of hook_menu().
File
- ./
oauth_common.pages.inc, line 36
Code
function oauth_common_page_authorized($csid = NULL) {
// If we have an oauth_token we're acting as a consumer and just got authorized
if (!empty($_GET['oauth_token'])) {
//TODO: Add documentation on how to use the callback url with
$consumer = $csid ? DrupalOAuthConsumer::loadById($csid, FALSE) : FALSE;
if ($consumer) {
$request_token = DrupalOAuthToken::loadByKey($_GET['oauth_token'], $consumer, OAUTH_COMMON_TOKEN_TYPE_REQUEST);
}
else {
// Backwards compatibility with 6.x-3.0-beta3
$request_token = DrupalOAuthToken::load($_GET['oauth_token'], FALSE);
$consumer = $request_token ? $request_token->consumer : FALSE;
}
if (!empty($request_token)) {
$client = new DrupalOAuthClient($consumer, $request_token);
$verifier = isset($_GET['oauth_verifier']) ? $_GET['oauth_verifier'] : NULL;
$access_token = $client
->getAccessToken(NULL, array(
'verifier' => $verifier,
));
if ($access_token) {
// We recieved a new token - save it
if (!$access_token->in_database) {
$access_token
->write();
}
$request_token
->delete();
module_invoke_all('oauth_common_authorized', $consumer, $access_token, $request_token);
}
}
}
return t('The application has been authorized');
}