You are here

public function TwitterAuthManager::getAuthenticationUrl in Open Social 8.4

Same name and namespace in other branches
  1. 8.9 modules/custom/social_auth_twitter/src/TwitterAuthManager.php \Drupal\social_auth_twitter\TwitterAuthManager::getAuthenticationUrl()
  2. 8 modules/custom/social_auth_twitter/src/TwitterAuthManager.php \Drupal\social_auth_twitter\TwitterAuthManager::getAuthenticationUrl()
  3. 8.2 modules/custom/social_auth_twitter/src/TwitterAuthManager.php \Drupal\social_auth_twitter\TwitterAuthManager::getAuthenticationUrl()
  4. 8.3 modules/custom/social_auth_twitter/src/TwitterAuthManager.php \Drupal\social_auth_twitter\TwitterAuthManager::getAuthenticationUrl()
  5. 8.5 modules/custom/social_auth_twitter/src/TwitterAuthManager.php \Drupal\social_auth_twitter\TwitterAuthManager::getAuthenticationUrl()
  6. 8.6 modules/custom/social_auth_twitter/src/TwitterAuthManager.php \Drupal\social_auth_twitter\TwitterAuthManager::getAuthenticationUrl()
  7. 8.7 modules/custom/social_auth_twitter/src/TwitterAuthManager.php \Drupal\social_auth_twitter\TwitterAuthManager::getAuthenticationUrl()
  8. 8.8 modules/custom/social_auth_twitter/src/TwitterAuthManager.php \Drupal\social_auth_twitter\TwitterAuthManager::getAuthenticationUrl()

Returns the login URL where user will be redirected for authentication.

Parameters

string $type: Type of action. "login" or "register".

array $scope: List of permissions which should be asked during authentication.

Return value

string Absolute URL.

Overrides AuthManagerInterface::getAuthenticationUrl

File

modules/custom/social_auth_twitter/src/TwitterAuthManager.php, line 37

Class

TwitterAuthManager
Manages the authorization process before getting a long lived access token.

Namespace

Drupal\social_auth_twitter

Code

public function getAuthenticationUrl($type, array $scope = [
  'read',
]) {
  $request_token = $this->sdk
    ->oauth('oauth/request_token', [
    'oauth_callback' => $this
      ->getRedirectUrl($type),
    'x_auth_access_type' => current($scope),
  ]);
  $data_handler = \Drupal::service('plugin.network.manager')
    ->createInstance('social_auth_twitter')
    ->getDataHandler();
  $data_handler
    ->set('oauth_token', $request_token['oauth_token']);
  $data_handler
    ->set('oauth_token_secret', $request_token['oauth_token_secret']);
  return $this->sdk
    ->url('oauth/authorize', [
    'oauth_token' => $request_token['oauth_token'],
  ]);
}