diff --git a/domain-server/resources/describe-settings.json b/domain-server/resources/describe-settings.json index 14c15e1e3d..ba019e3fe7 100644 --- a/domain-server/resources/describe-settings.json +++ b/domain-server/resources/describe-settings.json @@ -87,7 +87,13 @@ { "name": "oauth2_url_base", "label": "Authentication URL Base", - "help": "The URL base that the Interface and domain-server will use to make API requests.", + "help": "The URL base that the Interface will use to login via OAuth2.", + "advanced": true + }, + { + "name": "wordpress_url_base", + "label": "WordPress API URL Base", + "help": "The URL base that the domain server will use to make WordPress API calls. Typically \"http://oursite.com/wp-json/\". However, if using non-pretty permalinks or otherwise get a 404 error then use \"http://oursite.com/?rest_route=/\".", "advanced": true } ] diff --git a/domain-server/src/DomainGatekeeper.cpp b/domain-server/src/DomainGatekeeper.cpp index 210dabece1..29667b0fd5 100644 --- a/domain-server/src/DomainGatekeeper.cpp +++ b/domain-server/src/DomainGatekeeper.cpp @@ -450,6 +450,7 @@ SharedNodePointer DomainGatekeeper::processAssignmentConnectRequest(const NodeCo } const QString AUTHENTICATION_OAUTH2_URL_BASE = "authentication.oauth2_url_base"; +const QString AUTHENTICATION_WORDPRESS_URL_BASE = "authentication.wordpress_url_base"; const QString MAXIMUM_USER_CAPACITY = "security.maximum_user_capacity"; const QString MAXIMUM_USER_CAPACITY_REDIRECT_LOCATION = "security.maximum_user_capacity_redirect_location"; @@ -1235,13 +1236,15 @@ void DomainGatekeeper::requestDomainUser(const QString& username, const QString& } _inFlightDomainUserIdentityRequests.insert(username, QPair(accessToken, refreshToken)); - QString API_BASE = "http://127.0.0.1:9001/wp-json/"; - // Typically "http://oursite.com/wp-json/". - // However, if using non-pretty permalinks or otherwise get a 404 error then use "http://oursite.com/?rest_route=/". + QString apiBase = _server->_settingsManager.valueForKeyPath(AUTHENTICATION_WORDPRESS_URL_BASE).toString(); + if (!apiBase.endsWith("/")) { + apiBase += "/"; + } - // ####### TODO: Confirm API w.r.t. OAuth2 plugin's capabilities. // Get data pertaining to "me", the user who generated the access token. - QString API_ROUTE = "wp/v2/users/me?context=edit&_fields=id,username,roles"; + // ####### TODO: Confirm API_ROUTE w.r.t. OAuth2 plugin's capabilities. + QString API_ROUTE = "wp/v2/users/me?context=edit&_fields=id,username,roles"; + QUrl domainUserURL = apiBase + API_ROUTE; // ####### TODO: Append a random key to check in response? @@ -1254,8 +1257,6 @@ void DomainGatekeeper::requestDomainUser(const QString& username, const QString& QByteArray formData; // No data to send. - QUrl domainUserURL = API_BASE + API_ROUTE; - domainUserURL = "http://localhost:9002/resource"; // ####### TODO: Delete request.setUrl(domainUserURL); request.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true); diff --git a/libraries/networking/src/NodeList.cpp b/libraries/networking/src/NodeList.cpp index 539d044c1e..e02a8dd56e 100644 --- a/libraries/networking/src/NodeList.cpp +++ b/libraries/networking/src/NodeList.cpp @@ -501,6 +501,7 @@ void NodeList::sendDomainServerCheckIn() { packetStream << domainAccountManager->getUsername(); if (!domainAccountManager->getAccessToken().isEmpty()) { packetStream << (domainAccountManager->getAccessToken() + ":" + domainAccountManager->getRefreshToken()); + } } }