function google_analytics_reports_oauth_callback_validate in Google Analytics Reports 6
Validation handler. Verify that we have OAuth tokens. If so, request the Access Token.
File
- ./
google_analytics_api.pages.inc, line 170 - Admin and OAuth callbacks.
Code
function google_analytics_reports_oauth_callback_validate($form, &$form_state) {
$key = variable_get('google_analytics_reports_consumer_key', 'anonymous');
$secret = variable_get('google_analytics_reports_consumer_secret', 'anonymous');
$form_state['google_analytics_reports_oauth'] = $_SESSION['google_analytics_reports_oauth'];
unset($_SESSION['google_analytics_reports_oauth']);
$token = $form_state['google_analytics_reports_oauth']['token'];
if (!is_array($token) || !$key || !$secret) {
form_set_error('oauth_token', t('Invalid Google Analytics OAuth request'));
}
if ($token['oauth_token'] != $form_state['values']['oauth_token']) {
form_set_error('oauth_token', t('Invalid OAuth token.'));
}
module_load_include('inc', 'google_analytics_api', 'GAFeed.lib');
$GAFeed = new GAFeed($key, $secret, $token['oauth_token'], $token['oauth_token_secret']);
/* Google required the verifier */
$GAFeed
->setVerifier($form_state['values']['oauth_verifier']);
$response = $GAFeed
->getAccessToken();
$form_state['google_analytics_reports_oauth']['response'] = $response;
}