File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -57,15 +57,15 @@ public function tokenFromCode($code): array
5757 ]
5858 );
5959
60- $ response = \json_decode ($ response ->getBody ()->getContents (), true ) ?? [];
60+ $ body = \json_decode ($ response ->getBody ()->getContents (), true ) ?? [];
6161
62- if (empty ($ response ['data ' ])) {
63- throw new AuthorizeFailedException ('Invalid token response ' , $ response );
62+ if (empty ($ body ['data ' ]) || $ body [ ' data ' ][ ' error_code ' ] != 0 ) {
63+ throw new AuthorizeFailedException ('Invalid token response ' , $ body );
6464 }
6565
66- $ this ->withOpenId ($ response ['data ' ]['openid ' ]);
66+ $ this ->withOpenId ($ body ['data ' ]['open_id ' ]);
6767
68- return $ this ->normalizeAccessTokenResponse ($ response ['data ' ]);
68+ return $ this ->normalizeAccessTokenResponse ($ body ['data ' ]);
6969 }
7070
7171 /**
@@ -109,7 +109,9 @@ protected function getUserByToken(string $token): array
109109 ]
110110 );
111111
112- return \json_decode ($ response ->getBody (), true ) ?? [];
112+ $ body = \json_decode ($ response ->getBody ()->getContents (), true );
113+
114+ return $ body ['data ' ] ?? [];
113115 }
114116
115117 /**
You can’t perform that action at this time.
0 commit comments