Exemplo n.º 1
0
 public function test()
 {
     $Error1 = Error::initializeByString('{
         "error": "invalid_request"
     }');
     $this->assertFalse($Error1->isInvalidClient());
     $this->assertFalse($Error1->isInvalidGrant());
     $Error2 = Error::initializeByString('{
         "error": "invalid_client"
     }');
     $this->assertTrue($Error2->isInvalidClient());
     $this->assertFalse($Error2->isInvalidGrant());
     $Error3 = Error::initializeByString('{
         "error": "invalid_grant"
     }');
     $this->assertFalse($Error3->isInvalidClient());
     $this->assertTrue($Error3->isInvalidGrant());
 }
Exemplo n.º 2
0
 /**
  * Get access by refresh token
  * @param string $refreshToken refresh token
  * @return Error|Token Google Api response object
  */
 public function refresh($refreshToken)
 {
     $Request = $this->getRequest(self::ENDPOINT_ACCESS_TOKEN_REQUEST);
     $Request->addPostField('client_id', $this->getClientId())->addPostField('client_secret', $this->getClientSecret())->addPostField('refresh_token', $refreshToken)->addPostField('grant_type', self::GRANT_TYPE_REFRESH);
     try {
         $Token = Token::initializeByString($Request->send());
         $this->setToken($Token);
         return $Token;
     } catch (HttpClientErrorCodeException $ex) {
         return Error::initializeByString($ex->getMessage());
     }
 }