예제 #1
0
 /**
  * Prepare the actual HttpResponse for the token
  *
  * @param  AccessToken       $accessToken
  * @param  RefreshToken|null $refreshToken
  * @param  bool              $useRefreshTokenScopes
  * @return ResponseInterface
  */
 protected function prepareTokenResponse(AccessToken $accessToken, RefreshToken $refreshToken = null, $useRefreshTokenScopes = false)
 {
     $owner = $accessToken->getOwner();
     $scopes = $useRefreshTokenScopes ? $refreshToken->getScopes() : $accessToken->getScopes();
     $responseBody = ['access_token' => $accessToken->getToken(), 'token_type' => 'Bearer', 'expires_in' => $accessToken->getExpiresIn(), 'scope' => implode(' ', $scopes), 'owner_id' => $owner ? $owner->getTokenOwnerId() : null];
     if (null !== $refreshToken) {
         $responseBody['refresh_token'] = $refreshToken->getToken();
     }
     return new Response\JsonResponse(array_filter($responseBody));
 }
 /**
  * @return RefreshToken
  */
 private function getValidRefreshToken()
 {
     $refreshToken = new RefreshToken();
     $refreshToken->setToken('azerty_refresh');
     $refreshToken->setScopes('read');
     $validDate = new DateTime();
     $validDate->add(DateInterval::createFromDateString('3600 seconds'));
     $refreshToken->setExpiresAt($validDate);
     return $refreshToken;
 }
 /**
  * @return RefreshToken
  */
 private function getValidRefreshToken()
 {
     $refreshToken = new RefreshToken();
     $refreshToken->setToken('azerty_refresh');
     $refreshToken->setScopes('read');
     $validDate = new DateTime();
     $validDate->add(new DateInterval('P1D'));
     $refreshToken->setExpiresAt($validDate);
     return $refreshToken;
 }
 public function testSupportLongLiveToken()
 {
     $accessToken = new RefreshToken();
     $this->assertFalse($accessToken->isExpired());
 }