Oauth2 重定向调用缺少参数
Oath2 redirect call is missing parameters
我正在尝试使用使用 OAuth2 进行身份验证的家族历史 Web 服务进行身份验证。身份验证的基本工作流程是我针对请求身份验证会话的 Web 服务提交获取请求。它 returns 在响应正文中 HTML 包含一些用于用户名和密码的登录组件的代码。然后,我的 PHP 应用程序将 html 代码回显给浏览器。然后最终用户可以输入他或她的用户名和密码,然后提交给网络服务。这是行为变得不清楚的地方。理论上,Web 服务应该重定向到一个预定义的重定向 URI,其中一些参数包含在 URL 中。然而,在实践中,提交密码重定向到预先注册的重定向 URI,但 URL 中没有包含任何参数。我的项目主要是用 PHP 编写的。这是发出身份验证会话初始请求的代码片段。
function logOn($mainURL, $credentials)
{
// create a new HTTP_Request object to be used in the login process
$request = new HTTP_Request();
// set the URL of the HTTP_Request object to the family search identity/login endpoint
$request->setUrl("https://web-service/authentication/path?response_type=code&client_id=".$credentials['key']."&redirect_uri=https://www.myredirectPage.edu/");
$request->_useBrackets = false;
$request->addHeader("User-Agent", $credentials['agent']);
$request->addHeader("Accept","text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
$request->sendRequest();
//HTML_HEADER;
//the response will come in the form of an html file
$responseHtml = $request->getResponseBody();
//Dynamically load html from request body onto the browser to allow for authentication
echo $responseHtml;
return $credentials;
}
最终用户将使用加载的 html 组件输入他们的登录凭据并点击提交。 Web 服务然后重定向到我的重定向身份验证页面。下面提供了代码。
<?php
// process client request (Via url)
//gather code parameters from the redirect url.
if (isset($_GET['code']))
{
echo $_GET['code'];
}
else
{
echo "code not returned";
}
if (isset($_GET['error']))
{
echo $_GET['error'];
}
else
{
echo "error not returned";
}
?>
在此先感谢您提供的任何帮助。
当我使用 Google Chrome 的网络调试器工具时,我看到我的项目正在对 Javascript 和 Css 资源进行意外搜索,所有这些都导致404(未找到)错误。仔细检查后,我可以看到这些资源是 Web 服务服务器上资源的相对路径。而不是寻找“https://webService.net/js/importantJavascript.js' (an existing file located on the service's web server), it was trying to find 'https://mywebpage.edu/js/importantJavascript.js”(不存在的文件路径)。
我正在尝试使用使用 OAuth2 进行身份验证的家族历史 Web 服务进行身份验证。身份验证的基本工作流程是我针对请求身份验证会话的 Web 服务提交获取请求。它 returns 在响应正文中 HTML 包含一些用于用户名和密码的登录组件的代码。然后,我的 PHP 应用程序将 html 代码回显给浏览器。然后最终用户可以输入他或她的用户名和密码,然后提交给网络服务。这是行为变得不清楚的地方。理论上,Web 服务应该重定向到一个预定义的重定向 URI,其中一些参数包含在 URL 中。然而,在实践中,提交密码重定向到预先注册的重定向 URI,但 URL 中没有包含任何参数。我的项目主要是用 PHP 编写的。这是发出身份验证会话初始请求的代码片段。
function logOn($mainURL, $credentials)
{
// create a new HTTP_Request object to be used in the login process
$request = new HTTP_Request();
// set the URL of the HTTP_Request object to the family search identity/login endpoint
$request->setUrl("https://web-service/authentication/path?response_type=code&client_id=".$credentials['key']."&redirect_uri=https://www.myredirectPage.edu/");
$request->_useBrackets = false;
$request->addHeader("User-Agent", $credentials['agent']);
$request->addHeader("Accept","text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
$request->sendRequest();
//HTML_HEADER;
//the response will come in the form of an html file
$responseHtml = $request->getResponseBody();
//Dynamically load html from request body onto the browser to allow for authentication
echo $responseHtml;
return $credentials;
}
最终用户将使用加载的 html 组件输入他们的登录凭据并点击提交。 Web 服务然后重定向到我的重定向身份验证页面。下面提供了代码。
<?php
// process client request (Via url)
//gather code parameters from the redirect url.
if (isset($_GET['code']))
{
echo $_GET['code'];
}
else
{
echo "code not returned";
}
if (isset($_GET['error']))
{
echo $_GET['error'];
}
else
{
echo "error not returned";
}
?>
在此先感谢您提供的任何帮助。
当我使用 Google Chrome 的网络调试器工具时,我看到我的项目正在对 Javascript 和 Css 资源进行意外搜索,所有这些都导致404(未找到)错误。仔细检查后,我可以看到这些资源是 Web 服务服务器上资源的相对路径。而不是寻找“https://webService.net/js/importantJavascript.js' (an existing file located on the service's web server), it was trying to find 'https://mywebpage.edu/js/importantJavascript.js”(不存在的文件路径)。