File tree 1 file changed +31
-0
lines changed 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments