public function OpenIDConnectClientBase::authorize in OpenID Connect / OAuth client 7
Redirects the user to the authorization endpoint.
The authorization endpoint authenticates the user and returns them to the redirect_uri specified previously with an authorization code that can be exchanged for an access token.
Parameters
string $scope: Name of scope(s) that with user consent will provide access to otherwise restricted user data. Defaults to "openid email".
Overrides OpenIDConnectClientInterface::authorize
File
- includes/
OpenIDConnectClientBase.class.php, line 115 - Base class for OpenID Connect clients.
Class
- OpenIDConnectClientBase
- Base class for OpenID Connect clients.
Code
public function authorize($scope = 'openid email') {
$redirect_uri = OPENID_CONNECT_REDIRECT_PATH_BASE . '/' . $this->name;
$url_options = array(
'query' => array(
'client_id' => $this
->getSetting('client_id'),
'response_type' => 'code',
'scope' => $scope,
'redirect_uri' => url($redirect_uri, array(
'absolute' => TRUE,
)),
'state' => openid_connect_create_state_token(),
),
);
$endpoints = $this
->getEndpoints();
// Clear $_GET['destination'] because we need to override it.
unset($_GET['destination']);
drupal_goto($endpoints['authorization'], $url_options);
}