function it_issues_refresh_token_for_given_access_token(IRefreshTokenStorage $refreshTokenStorage, IAccessToken $accessToken, IRefreshToken $refreshToken, IUser $user, IClient $client, IScope $scope)
 {
     $accessToken->getUser()->willReturn($user)->shouldBeCalled();
     $accessToken->getClient()->willReturn($client)->shouldBeCalled();
     $accessToken->getScopes()->willReturn([$scope])->shouldBeCalled();
     $refreshTokenStorage->generate($user, $client, [$scope])->willReturn($refreshToken)->shouldBeCalled();
     $this->issueToken($accessToken)->shouldReturnAnInstanceOf('OAuth2\\Storage\\IRefreshToken');
 }
 /**
  * Issues refresh token for given access token
  *
  * @param IAccessToken $accessToken
  *
  * @return \OAuth2\Storage\IRefreshToken
  */
 public function issueToken(IAccessToken $accessToken)
 {
     $scopes = $accessToken->getScopes();
     // in case of doctrine collections, etc
     if ($scopes instanceof \Traversable) {
         $scopes = iterator_to_array($scopes);
     }
     return $this->refreshTokenStorage->generate($accessToken->getUser(), $accessToken->getClient(), $scopes);
 }
 /**
  * Gets redirect uri (used in redirecting back to client)
  *
  * @return string
  */
 public function getRedirectUri()
 {
     $scopes = array_map(function (IScope $scope) {
         return $scope->getId();
     }, $this->accessToken->getScopes());
     $query = ['access_token' => $this->accessToken->getId(), 'expires_in' => $this->accessToken->getExpiresAt() - time(), 'token_type' => $this->tokenTypeName, 'scope' => join(' ', $scopes)];
     if ($this->state) {
         $query['state'] = $this->state;
     }
     ksort($query);
     // sort query params by key
     return $this->redirectUri . '#' . http_build_query($query);
 }
 function it_authorizes_access_to_given_scope(IAccessToken $accessToken)
 {
     $accessToken->hasScope('edit')->willReturn(true)->shouldBeCalled();
     $this->isAllowed('edit')->shouldReturn(true);
 }
 function it_should_return_scopes_from_access_token(IAccessToken $accessToken)
 {
     $accessToken->getScopes()->willReturn([])->shouldBeCalled();
     $this->getScopes()->shouldReturn([]);
 }