Skip to content

Commit ea3a44e

Browse files
committed
add router
1 parent 1806769 commit ea3a44e

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace OAuthServer\Controller;
4+
5+
use Hyperf\HttpServer\Annotation\Controller;
6+
use Hyperf\HttpServer\Annotation\RequestMapping;
7+
use Hyperf\HttpServer\Contract\RequestInterface;
8+
use Hyperf\HttpServer\Contract\ResponseInterface;
9+
use OAuthServer\Exception\AuthenticationException;
10+
use League\OAuth2\Server\Exception\OAuthServerException;
11+
12+
13+
/**
14+
* @Controller()
15+
*/
16+
class TokenIssueController
17+
{
18+
/**
19+
* @RequestMapping(path="/oauth/token", methods="post")
20+
*/
21+
public function issueToken(RequestInterface $request, ResponseInterface $response)
22+
{
23+
try {
24+
return $this->server->respondToAccessTokenRequest($request, $response);
25+
} catch (OAuthServerException $e) {
26+
return $e->generateHttpResponse($response);
27+
} catch (\Exception $e) {
28+
throw new AuthenticationException("Unauthorize: {$e->getMessage()}");
29+
}
30+
}
31+
}

0 commit comments

Comments
 (0)