| Conditions | 3 |
| Paths | 3 |
| Total Lines | 35 |
| Code Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 34 | public function getAccessToken(){ |
||
| 35 | $accessToken = null; |
||
| 36 | |||
| 37 | if($this->exp <= time()){ |
||
| 38 | $sTime = time(); |
||
| 39 | |||
| 40 | $jsonToken = array( |
||
| 41 | "iss"=>$this->iss, |
||
| 42 | "scope"=>"https://www.googleapis.com/auth/firebase.database https://www.googleapis.com/auth/userinfo.email", |
||
| 43 | "aud"=>"https://www.googleapis.com/oauth2/v4/token", |
||
| 44 | "exp"=>time()+$this->tokenLifeTime, |
||
| 45 | "iat"=>time() |
||
| 46 | ); |
||
| 47 | $jwt = JWT::encode($jsonToken, $this->key, 'RS256'); |
||
| 48 | |||
| 49 | $OAuthResponse = Requests::post('https://www.googleapis.com/oauth2/v4/token',null,array( |
||
| 50 | 'grant_type' => 'urn:ietf:params:oauth:grant-type:jwt-bearer', |
||
| 51 | 'assertion' => $jwt |
||
| 52 | )); |
||
| 53 | |||
| 54 | if($OAuthResponse->status_code == 200){ |
||
| 55 | $accessToken = json_decode($OAuthResponse->body)->access_token; |
||
| 56 | $this->accessToken = $accessToken; |
||
| 57 | |||
| 58 | //set expire time |
||
| 59 | $eTime = time(); |
||
| 60 | $this->exp = $sTime - $eTime + $this->tokenLifeTime; |
||
| 61 | } |
||
| 62 | } |
||
| 63 | else{ |
||
| 64 | $accessToken = $this->accessToken; |
||
| 65 | } |
||
| 66 | |||
| 67 | return $accessToken; |
||
| 68 | } |
||
| 69 | } |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.