代码拉取完成,页面将自动刷新
<?php
/***
* 授权页面
*/
// include our OAuth2 Server object
require_once __DIR__.'/server.php';
$request = OAuth2\Request::createFromGlobals();
$response = new OAuth2\Response();
// validate the authorize request
if (!$server->validateAuthorizeRequest($request, $response)) {
$response->send();
die;
}
// display an authorization form
if (empty($_POST)) {
exit('
<form method="post">
<label>授权TestClient?</label><br />
<p><span>账号:</span><input type="text" name="username" value=""></p>
<p><span>密码:</span><input type="password" name="password" value="" /></p>
<input type="submit" name="authorized" value="yes">
<input type="submit" name="authorized" value="no">
</form>');
}
// print the authorization code if the user has authorized your client
$is_authorized = ($_POST['authorized'] === 'yes');
//todo::账号密码 对应的需要切换到平台的账号 去做验证 这里固定值
$user_id = '1234';
$server->handleAuthorizeRequest($request, $response, $is_authorized,$user_id);
if ($is_authorized) {
// this is only here so that you get to see your code in the cURL request. Otherwise, we'd redirect back to the client
$code = substr($response->getHttpHeader('Location'), strpos($response->getHttpHeader('Location'), 'code=')+5, 40);
$response->setRedirect(302,$_GET['redirect_uri'].'?code='.$code."&state=".$_GET['state']);
//exit("SUCCESS! Authorization Code: $code");
}
$response->send();
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。