Files
usercenter_old/oauth2/auth.php
2022-06-17 21:45:51 +08:00

29 lines
890 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
require_once __DIR__.'/server.php';
$request = OAuth2\Request::createFromGlobals();
$response = new OAuth2\Response();
if (!$server->validateAuthorizeRequest($request, $response)) {
$code = array(
"code"=>400,
"msg"=>$response->getParameter("error_description")
);
die(json_encode($code,JSON_UNESCAPED_UNICODE));
}
if (empty($_POST)) {
$scopes=$_GET['scope'];
if (empty($scopes)){
$code = array(
"code"=>401,
"msg"=>"权限点信息scope不应为空"
);
die(json_encode($code,JSON_UNESCAPED_UNICODE));
}
include ROOT.'page/oauth2/auth.php';
die();
}
// print the authorization code if the user has authorized your client
$is_authorized = ($_POST['authorized'] === 'yes');
$server->handleAuthorizeRequest($request, $response, $is_authorized,$cookie::get('uid'));
$response->send();