public function OauthInteractions::authorize in FormAssembly 8
Assemble the authorization url and redirect to it.
1 string reference to 'OauthInteractions::authorize'
File
- src/
Controller/ OauthInteractions.php, line 73
Class
- OauthInteractions
- Utility class for interacting with FormAssembly for authorization.
Namespace
Drupal\formassembly\ControllerCode
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;
}