public function testAccessTokenGetters()
 {
     $data = ['access_token' => 'testToken', 'token_type' => 'bearer', 'expires_in' => 300, 'scope' => 'profile administration', 'refresh_token' => 'testRefreshToken'];
     $token = new AccessToken($data['access_token'], $data['token_type'], $data);
     $this->assertEquals($data['access_token'], $token->getToken());
     $this->assertEquals($data['token_type'], $token->getType());
     $this->assertEquals($data['scope'], $token->getScope());
     $this->assertGreaterThan(time(), $token->getExpires()->getTimestamp());
     $this->assertFalse($token->isExpired());
     $this->assertEquals($data, $token->getData());
     $this->assertEquals('refresh_token', $token->getRefreshToken()->getType());
     $this->assertEquals($data['refresh_token'], $token->getRefreshToken()->getToken());
 }
Esempio n. 2
0
 /**
  * Save an access token to the session.
  *
  * @param AccessToken $token
  */
 protected function addTokenToSession(AccessToken $token)
 {
     $this->session->set('accessToken', $token->getToken());
     $this->session->set('tokenType', $token->getType());
     if ($token->getExpires()) {
         $this->session->set('expires', $token->getExpires()->getTimestamp());
     }
     if ($token->getRefreshToken()) {
         $this->session->set('refreshToken', $token->getRefreshToken()->getToken());
     }
 }