fix auth token
[pharext/pharext.org] / app / Github / API / Users / ReadAuthToken.php
1 <?php
2
3 namespace app\Github\API\Users;
4
5 use app\Github\API\Call;
6 use app\Github\Exception\RequestException;
7 use http\Client\Request;
8 use http\Client\Response;
9 use http\QueryString;
10
11 class ReadAuthToken extends Call
12 {
13 protected function request() {
14 $request = new Request("POST", "https://github.com/login/oauth/access_token", [
15 "Accept" => "application/json",
16 ]);
17 $request->getBody()->append(new QueryString($this->args));
18 return $request;
19 }
20
21 protected function response(Response $response) {
22 if ($response->getResponseCode() >= 400 || null === ($json = json_decode($response->getBody()))) {
23 throw new RequestException($response);
24 }
25 return [$json];
26 }
27
28 function getCacheKey() {
29 return null;
30 }
31 }