public function test()
 {
     $Response1 = ResponseFactory::createResponse('{
         "access_token": "kjdhfldjfhgldsjhfglkdjfg9ds8fg0sdf8gsd8fg",
         "token_type": "session",
         "refresh_token": "klsdjhf0e9dyfasduhfpasdfasdfjaspdkfjp"
     }');
     $this->assertInstanceOf(Token::class, $Response1);
     $this->assertEquals('kjdhfldjfhgldsjhfglkdjfg9ds8fg0sdf8gsd8fg', $Response1->getAccessToken());
     $this->assertEquals('klsdjhf0e9dyfasduhfpasdfasdfjaspdkfjp', $Response1->getRefreshToken());
     $this->assertTrue($Response1->hasRefreshToken());
     $this->assertEquals(Token::TYPE_SESSION, $Response1->getTokenType());
     $Response2 = ResponseFactory::createResponse('{
         "error": "some_error",
         "error_description": "Some error description"
     }');
     $this->assertInstanceOf(Error::class, $Response2);
     $this->assertEquals('some_error', $Response2->getError());
     $this->assertEquals('Some error description', $Response2->getDescription());
     $Response3 = ResponseFactory::createResponse('https://example.com/oauth2callback?error=some_error&error_description=Some error description');
     $this->assertInstanceOf(Error::class, $Response3);
     $this->assertEquals('some_error', $Response3->getError());
     $this->assertEquals('Some error description', $Response3->getDescription());
     $Response4 = ResponseFactory::createResponse('https://example.com/oauth2callback?code=someCode/1');
     $this->assertInstanceOf(Code::class, $Response4);
     $this->assertEquals('someCode/1', $Response4->getCode());
 }
Esempio n. 2
0
 /**
  * Get access token by refresh token
  * @param string $refreshToken refresh token value
  * @return Token|Error token or error instance
  */
 public function refresh($refreshToken)
 {
     $Request = $this->getRequest(self::ENDPOINT_TOKEN_REQUEST);
     $Request->addPostField('refresh_token', $refreshToken)->addPostField('grant_type', self::GRANT_TYPE_REFRESH_TOKEN)->addPostField('client_id', $this->getClientId())->addPostField('client_secret', $this->getClientSecret());
     return ResponseFactory::createResponse($Request->send());
 }