You are here

function salesforce_oauth_callback in Salesforce Suite 7.3

Callback for the oauth redirect URI.

Exchanges an authorization code for an access token.

1 string reference to 'salesforce_oauth_callback'
salesforce_menu in ./salesforce.module
Implements hook_menu().

File

./salesforce.module, line 327
API and module for Salesforce integration.

Code

function salesforce_oauth_callback() {

  // If no code is provided, return access denied.
  if (!isset($_GET['code'])) {
    return drupal_access_denied();
  }
  $salesforce = salesforce_get_api();
  if ($salesforce
    ->requestToken($_GET['code'])) {
    salesforce_set_message(t('Salesforce OAUTH2 authorization successful.'));

    // Rebuild the menu so the mappings links are now available.
    menu_rebuild();
  }
  else {
    salesforce_set_message(t('Salesforce OAUTH2 authorization failed, likely due to inadequate OAUTH scope. Ensure your app has scope %scope selected.', array(
      '%scope' => 'Perform requests on your behalf at any time',
    )), 'warning');
  }
  drupal_goto('admin/config/salesforce/authorize');
}