You are here

public function Oauth::getAuthLink in Media: Acquia DAM 8

Get the URL to redirect a user to to start the oauth process.

Return value

string The URL to redirect to.

Overrides OauthInterface::getAuthLink

File

src/Oauth.php, line 154

Class

Oauth
OAuth Class.

Namespace

Drupal\media_acquiadam

Code

public function getAuthLink() {
  $client_id = $this->config
    ->get('client_id');
  $token = $this->csrfTokenGenerator
    ->get('media_acquiadam.oauth');
  $redirect_uri = $this->urlGenerator
    ->generateFromRoute('media_acquiadam.auth_finish', [
    'auth_finish_redirect' => $this->authFinishRedirect,
  ], [
    'absolute' => TRUE,
  ]);
  return "{$this->damApiBase}/oauth2/authorize?response_type=code&state={$token}&redirect_uri={$redirect_uri}&client_id={$client_id}";
}