| Conditions | 2 |
| Paths | 2 |
| Total Lines | 24 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 38 | protected function requestAccessToken() |
||
| 39 | { |
||
| 40 | $currentTimestamp = time(); |
||
| 41 | $this->expireTimestamp = $currentTimestamp + $this->tokenLifeTime; |
||
| 42 | $jsonToken = array( |
||
| 43 | "iss" => $this->iss, |
||
| 44 | "scope" => "https://www.googleapis.com/auth/firebase.database https://www.googleapis.com/auth/userinfo.email", |
||
| 45 | "aud" => "https://www.googleapis.com/oauth2/v4/token", |
||
| 46 | "exp" => $this->expireTimestamp, |
||
| 47 | "iat" => $currentTimestamp |
||
| 48 | ); |
||
| 49 | $jwt = JWT::encode($jsonToken, $this->key, 'RS256'); |
||
| 50 | |||
| 51 | $OAuthResponse = Requests::post('https://www.googleapis.com/oauth2/v4/token', array(), array( |
||
| 52 | 'grant_type' => 'urn:ietf:params:oauth:grant-type:jwt-bearer', |
||
| 53 | 'assertion' => $jwt |
||
| 54 | )); |
||
| 55 | |||
| 56 | if ($OAuthResponse->status_code == 200) { |
||
| 57 | $this->accessToken = json_decode($OAuthResponse->body)->access_token; |
||
| 58 | return true; |
||
| 59 | } |
||
| 60 | return false; |
||
| 61 | } |
||
| 62 | |||
| 71 | } |