/**
  * @test
  */
 public function request_token_is_not_valid_when_verifier_is_missing()
 {
     $url = $this->createUrlWithTokenAndVerifier(self::TEST_TOKEN, '');
     $request = Request::create($url);
     $hasValidRequestToken = $this->oAuthUrlHelper->hasValidRequestToken($request, $this->requestToken);
     $this->assertFalse($hasValidRequestToken);
 }
Exemplo n.º 2
0
 /**
  * @param Request $request
  * @return RedirectResponse
  */
 public function authorize(Request $request)
 {
     $requestToken = $this->requestTokenStorage->getStoredRequestToken();
     $this->requestTokenStorage->removeStoredRequestToken();
     if ($requestToken === null || !$this->oAuthUrlHelper->hasValidRequestToken($request, $requestToken)) {
         return new Response('Invalid request token.', 500);
     }
     $accessToken = $this->oAuthService->getAccessToken($requestToken, $this->oAuthUrlHelper->getOAuthVerifier($request));
     try {
         $destination = $this->oAuthUrlHelper->getDestinationUri($request);
     } catch (\InvalidArgumentException $e) {
         return new Response($e->getMessage(), 400);
     }
     return $this->oAuthCallbackHandler->handle($accessToken, $destination);
 }