You are here

public function DrupalOAuthClient::getAuthorizationUrl in OAuth 1.0 6.3

Same name and namespace in other branches
  1. 7.4 includes/DrupalOAuthClient.inc \DrupalOAuthClient::getAuthorizationUrl()
  2. 7.3 includes/DrupalOAuthClient.inc \DrupalOAuthClient::getAuthorizationUrl()

Constructs the url that the user should be sent to to authorize the request token.

Parameters

string $endpoint: Optional. The endpoint path for the provider.

  • If you provide the full URL (e.g. "http://example.com/oauth/authorize"), then it will be used.
  • If you provide only the path (e.g. "oauth/authorize"), it will be converted into a full URL by prepending the provider_url.
  • If you provide nothing it will default to '/oauth/authorize'.

array $options: An associative array of additional optional options, with the following keys:

  • 'params' An associative array of parameters that should be included in the request.
  • 'callback' A full URL of where the user should be sent after the request token has been authorized. Only used by version OAUTH_COMMON_VERSION_1.

Return value

string The url.

File

includes/DrupalOAuthClient.inc, line 167

Class

DrupalOAuthClient

Code

public function getAuthorizationUrl($endpoint = NULL, $options = array()) {
  $options += array(
    'params' => array(),
    'callback' => NULL,
  );
  if (empty($endpoint)) {
    if (!empty($this->consumer->configuration['authorization_endpoint'])) {
      $endpoint = $this->consumer->configuration['authorization_endpoint'];
    }
    else {
      $endpoint = '/oauth/authorize';
    }
  }
  if ($this->version == OAUTH_COMMON_VERSION_1 && $options['callback']) {
    $options['params']['oauth_callback'] = $options['callback'];
  }
  $options['params']['oauth_token'] = $this->requestToken->key;
  $endpoint = $this
    ->getAbsolutePath($endpoint);
  $append_query = strpos($endpoint, '?') === FALSE ? '?' : '&';
  return $endpoint . $append_query . http_build_query($options['params'], NULL, '&');
}