You are here

public function OauthInteractions::authorize in FormAssembly 8

Assemble the authorization url and redirect to it.

1 string reference to 'OauthInteractions::authorize'
formassembly.routing.yml in ./formassembly.routing.yml
formassembly.routing.yml

File

src/Controller/OauthInteractions.php, line 73

Class

OauthInteractions
Utility class for interacting with FormAssembly for authorization.

Namespace

Drupal\formassembly\Controller

Code

public function authorize() {

  /** @var \Drupal\Core\Config\ImmutableConfig $formassembly_config */
  $credentials = $this->keyService
    ->getOauthKeys();
  $provider = new OauthProvider([
    'clientId' => $credentials['cid'],
    'clientSecret' => $credentials['secret'],
    'redirectUri' => Url::fromRoute('fa_form.authorize.store', [], [
      'absolute' => TRUE,
    ])
      ->toString(TRUE)
      ->getGeneratedUrl(),
    'baseUrl' => $this->apiAuthorize
      ->getUrl('base')
      ->toString(TRUE)
      ->getGeneratedUrl(),
  ]);
  $url = $provider
    ->getAuthorizationUrl();
  $response = new TrustedRedirectResponse($url);
  $response
    ->addCacheableDependency($url);
  return $response;
}