function it_should_issue_access_token_and_return_implicit_authorization_session(IAccessTokenStorage $accessTokenStorage, IScopeResolver $scopeResolver, IClientStorage $clientStorage, IClient $client, IRequest $request, ITokenType $tokenType, IUser $user, IAccessToken $accessToken, IScope $scope)
 {
     $request->query('client_id')->willReturn('test')->shouldBeCalled();
     $clientStorage->get('test')->willReturn($client)->shouldBeCalled();
     $client->isAllowedToUse($this)->willReturn(true)->shouldBeCalled();
     $request->query('redirect_uri')->willReturn('http://google.com')->shouldBeCalled();
     $client->getRedirectUri()->willReturn('http://google.com')->shouldBeCalled();
     $request->query('scope')->willReturn('scope1')->shouldBeCalled();
     $user->getScopes()->willReturn([])->shouldBeCalled();
     $scopeResolver->getDefaultScopes()->willReturn([$scope])->shouldBeCalled();
     $scopeResolver->intersect('scope1', [$scope])->willReturn([$scope])->shouldBeCalled();
     $request->query('state')->willReturn(null)->shouldBeCalled();
     $accessTokenStorage->generate($user, $client, [$scope])->willReturn($accessToken)->shouldBeCalled();
     $tokenType->getName()->willReturn('Bearer')->shouldBeCalled();
     $this->authorize($request, $user)->shouldReturnAnInstanceOf('OAuth2\\Security\\ImplicitSession');
 }
 function it_should_return_token_type_on_match(ITokenType $tokenType, IRequest $request)
 {
     $tokenType->match($request)->willReturn(true)->shouldBeCalled();
     $this->accept($tokenType);
     $this->resolve($request)->shouldReturn($tokenType);
 }
 /**
  * Authorizes request
  *
  * @param IRequest $request
  * @param IUser $user logged user
  *
  * @throws \OAuth2\Exception\InvalidClientException
  * @throws \OAuth2\Exception\InvalidRequestException
  * @throws \OAuth2\Exception\InvalidScopeException
  * @throws \OAuth2\Exception\UnauthorizedClientException
  * @return AuthorizationCodeSession
  */
 public function authorize(IRequest $request, IUser $user)
 {
     $requirements = parent::parseAuthorizationRequest($request, $user);
     $accessToken = $this->accessTokenStorage->generate($user, $requirements['client'], $requirements['scopes']);
     return new ImplicitSession($accessToken, $this->tokenType->getName(), $requirements['redirect_uri'], $requirements['state']);
 }