Plugin: OAuth2: Refector for provider options - refs BT#18776

pull/3905/head
Angel Fernando Quiroz Campos 5 years ago
parent 801bfc0fd0
commit 0538fb4917
  1. 60
      plugin/oauth2/src/OAuth2.php

@ -121,33 +121,49 @@ class OAuth2 extends Plugin
return $result ? $result : $result = new self();
}
/**
* @return GenericProvider
*/
public function getProvider()
public function getProvider(): GenericProvider
{
return new GenericProvider(
[
'clientId' => $this->get(self::SETTING_CLIENT_ID),
'clientSecret' => $this->get(self::SETTING_CLIENT_SECRET),
'redirectUri' => api_get_path(WEB_PLUGIN_PATH).'oauth2/src/callback.php',
$options = [
'clientId' => $this->get(self::SETTING_CLIENT_ID),
'clientSecret' => $this->get(self::SETTING_CLIENT_SECRET),
'redirectUri' => api_get_path(WEB_PLUGIN_PATH).'oauth2/src/callback.php',
'urlAuthorize' => $this->get(self::SETTING_AUTHORIZE_URL),
'urlResourceOwnerDetails' => $this->get(self::SETTING_RESOURCE_OWNER_DETAILS_URL),
];
// if ('' !== $scopeSeparator = (string) $this->get(self::SETTING_SCOPE_SEPARATOR)) {
// $options['scopeSeparator'] = $scopeSeparator;
// }
//
// if ('' !== $scopes = (string) $this->get(self::SETTING_SCOPES)) {
// $options['scopes'] = explode($scopeSeparator, $scopes);
// }
if ('' !== $urlAccessToken = (string) $this->get(self::SETTING_ACCESS_TOKEN_URL)) {
$options['urlAccessToken'] = $urlAccessToken;
}
if ('' !== $accessTokenMethod = (string) $this->get(self::SETTING_ACCESS_TOKEN_METHOD)) {
$options['accessTokenMethod'] = $accessTokenMethod;
}
'urlAuthorize' => $this->get(self::SETTING_AUTHORIZE_URL),
// 'scopes' => $this->get(self::SETTING_SCOPES) or null,
// 'scopeSeparator' => $this->get(self::SETTING_SCOPE_SEPARATOR) ?: ',',
// if ('' !== $accessTokenResourceOwnerId = (string) $this->get(self::SETTING_ACCESS_TOKEN_RESOURCE_OWNER_ID)) {
// $options['accessTokenResourceOwnerId'] = $accessTokenResourceOwnerId;
// }
'urlAccessToken' => $this->get(self::SETTING_ACCESS_TOKEN_URL),
'accessTokenMethod' => $this->get(self::SETTING_ACCESS_TOKEN_METHOD) ?: GenericProvider::METHOD_POST,
//'accessTokenResourceOwnerId' => $this->get(self::SETTING_ACCESS_TOKEN_RESOURCE_OWNER_ID)
// ?: GenericProvider::ACCESS_TOKEN_RESOURCE_OWNER_ID,
if ('' !== $responseError = (string) $this->get(self::SETTING_RESPONSE_ERROR)) {
$options['responseError'] = $responseError;
}
'urlResourceOwnerDetails' => $this->get(self::SETTING_RESOURCE_OWNER_DETAILS_URL),
if ('' !== $responseCode = (string) $this->get(self::SETTING_RESPONSE_CODE)) {
$options['responseCode'] = $responseCode;
}
'responseError' => $this->get(self::SETTING_RESPONSE_ERROR) ?: 'error',
'responseCode' => $this->get(self::SETTING_RESPONSE_CODE) ?: null,
'responseResourceOwnerId' => $this->get(self::SETTING_RESPONSE_RESOURCE_OWNER_ID) ?: 'id',
]
);
if ('' !== $responseResourceOwnerId = (string) $this->get(self::SETTING_RESPONSE_RESOURCE_OWNER_ID)) {
$options['responseResourceOwnerId'] = $responseResourceOwnerId;
}
return new GenericProvider($options);
}
/**

Loading…
Cancel
Save