Skip to content

Commit

Permalink
#304 Update OAuth and API URLs with correct prefixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ewhanson committed Dec 11, 2023
1 parent 9108212 commit f89d1dd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions OrcidProfilePlugin.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

define('ORCID_URL', 'https://orcid.org/');
define('ORCID_URL_SANDBOX', 'https://sandbox.orcid.org/');
define('ORCID_API_URL_PUBLIC', 'https://orcid.org/');
define('ORCID_API_URL_PUBLIC_SANDBOX', 'https://sandbox.orcid.org/');
define('ORCID_API_URL_PUBLIC', 'https://pub.orcid.org/');
define('ORCID_API_URL_PUBLIC_SANDBOX', 'https://pub.sandbox.orcid.org/');
define('ORCID_API_URL_MEMBER', 'https://api.orcid.org/');
define('ORCID_API_URL_MEMBER_SANDBOX', 'https://api.sandbox.orcid.org/');
define('ORCID_API_VERSION_URL', 'v3.0/');
Expand Down Expand Up @@ -192,9 +192,9 @@ function getSetting($contextId, $name) {

$config_value = $config_value ?? parent::getSetting($contextId, $name);
if ($name == 'orcidProfileAPIPath') {
if ($config_value == 'https://pub.orcid.org/') {
if ($config_value == 'https://orcid.org/') {
$config_value = ORCID_API_URL_PUBLIC;
} elseif ($config_value == 'https://pub.sandbox.orcid.org/') {
} elseif ($config_value == 'https://sandbox.orcid.org/') {
$config_value = ORCID_API_URL_PUBLIC_SANDBOX;
}
}
Expand Down
4 changes: 2 additions & 2 deletions pages/OrcidHandler.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function orcidAuthorize($args, $request)
// API request: Get an OAuth token and ORCID.
$response = $httpClient->request(
'POST',
$url = $plugin->getSetting($contextId, 'orcidProfileAPIPath') . OAUTH_TOKEN_URL,
$url = $plugin->getOrcidUrl() . OAUTH_TOKEN_URL,
[
'form_params' => [
'code' => $request->getUserVar('code'),
Expand Down Expand Up @@ -254,7 +254,7 @@ function orcidVerify($args, $request)
}

// fetch the access token
$url = $plugin->getSetting($contextId, 'orcidProfileAPIPath') . OAUTH_TOKEN_URL;
$url = $plugin->getOrcidUrl() . OAUTH_TOKEN_URL;

$httpClient = Application::get()->getHttpClient();
$header = ['Accept' => 'application/json'];
Expand Down

0 comments on commit f89d1dd

Please sign in to comment.