mirror of
https://github.com/elyby/oauth2-server.git
synced 2025-01-03 10:41:51 +05:30
Updated response code
This commit is contained in:
parent
29b09227ac
commit
cfd1c93a46
@ -39,14 +39,20 @@ $router->get('/authorize', function (Request $request) use ($server) {
|
|||||||
// First ensure the parameters in the query string are correct
|
// First ensure the parameters in the query string are correct
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$authParams = $server->getGrantType('authorization_code')->checkAuthorizeParams();
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
echo json_encode([
|
|
||||||
'error' => $e->errorType,
|
|
||||||
'message' => $e->getMessage()
|
|
||||||
]);
|
|
||||||
|
|
||||||
exit;
|
$authParams = $server->getGrantType('authorization_code')->checkAuthorizeParams();
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
|
||||||
|
return new Response(
|
||||||
|
json_encode([
|
||||||
|
'error' => $e->errorType,
|
||||||
|
'message' => $e->getMessage()
|
||||||
|
]),
|
||||||
|
$e->httpStatusCode,
|
||||||
|
$e->getHttpHeaders()
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Normally at this point you would show the user a sign-in screen and ask them to authorize the requested scopes
|
// Normally at this point you would show the user a sign-in screen and ask them to authorize the requested scopes
|
||||||
@ -72,14 +78,23 @@ $router->get('/authorize', function (Request $request) use ($server) {
|
|||||||
$router->post('/access_token', function (Request $request) use ($server) {
|
$router->post('/access_token', function (Request $request) use ($server) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$response = $server->getGrantType('authorization_code')->completeFlow();
|
|
||||||
} catch (\Exception $e) {
|
$response = $server->issueAccessToken();
|
||||||
echo json_encode([
|
return new Response(json_encode($response), 200, [
|
||||||
'error' => $e->errorType,
|
'Location' => $redirectUri
|
||||||
'message' => $e->getMessage()
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
exit;
|
} catch (\Exception $e) {
|
||||||
|
|
||||||
|
return new Response(
|
||||||
|
json_encode([
|
||||||
|
'error' => $e->errorType,
|
||||||
|
'message' => $e->getMessage()
|
||||||
|
]),
|
||||||
|
$e->httpStatusCode,
|
||||||
|
$e->getHttpHeaders()
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -87,5 +102,3 @@ $router->post('/access_token', function (Request $request) use ($server) {
|
|||||||
$dispatcher = $router->getDispatcher();
|
$dispatcher = $router->getDispatcher();
|
||||||
$response = $dispatcher->dispatch($request->getMethod(), $request->getPathInfo());
|
$response = $dispatcher->dispatch($request->getMethod(), $request->getPathInfo());
|
||||||
$response->send();
|
$response->send();
|
||||||
|
|
||||||
// var_dump(Capsule::getQueryLog());
|
|
||||||
|
Loading…
Reference in New Issue
Block a user