2) Returns CredentialTokenModel with json field token

@param Request $request
@return CredentialTokenModel
350677
public function getCredentials(Request $request)
    {
        $post = json_decode($request->getContent(), true);

        return new CredentialTokenModel($post[self::TOKEN_FIELD]);
    }
660429
public function fetch_request_token(&$request) {
    $this->get_version($request);

    $consumer = $this->get_consumer($request);

    // no token required for the initial token request
    $token = NULL;

    $this->check_signature($request, $consumer, $token);

    $new_token = $this->data_store->new_request_token($consumer);

    return $new_token;
  }
417510
public function getMyAssertionsAction(Request $request)
    {
        $user = $this->tokenStorage->getToken()->getUser();
        $assertions = $this->finder->search(Assertion::class, array_merge(
            $request->query->all(),
            ['hiddenFilters' => ['recipient' => $user->getUuid()]]
        ));

        return new JsonResponse($assertions);
    }
809065
public function fetchRequestToken(&$request)
    {
        $this->getVersion($request);
        
        $consumer = $this->getConsumer($request);
        
        // no token required for the initial token request
        $token = null;
        
        $this->checkSignature($request, $consumer, $token);
        
        // Rev A change
        $callback = $request->getParameter('oauth_callback');
        $new_token = $this->data_store->newRequestToken($consumer, $callback);
        
        return $new_token;
    }
623487
private function getSignature(Request $request)
    {
        switch ($this->getSignatureMethod()) {
            case self::SIGNATURE_RSA_SHA1:
                $signature = RSASHA1::generateSignature(
                    $this->config,
                    $this->getSBS($request),
                    $this->getSigningSecret()
                );

                break;
            case self::SIGNATURE_HMAC_SHA1:
                $signature = HMACSHA1::generateSignature(
                    $this->config,
                    $this->getSBS($request),
                    $this->getSigningSecret()
                );

                break;
            case self::SIGNATURE_PLAINTEXT:
                $signature = PLAINTEXT::generateSignature(
                    $this->config,
                    $this->getSBS($request),
                    $this->getSigningSecret()
                );

                break;
            default:
                throw new Exception(
                    "Invalid signature method [{$this->config['signature_method']}]"
                );
        }

        return $signature;
    }
382269
public function getCredentials(Request $request)
    {
        $tokenExtractor = $this->getTokenExtractor();

        if (!$tokenExtractor instanceof TokenExtractorInterface) {
            throw new \RuntimeException(sprintf('Method "%s::getTokenExtractor()" must return an instance of "%s".', __CLASS__, TokenExtractorInterface::class));
        }

        if (false === ($jsonWebToken = $tokenExtractor->extract($request))) {
            return;
        }

        $preAuthToken = new PreAuthenticationJWTUserToken($jsonWebToken);

        try {
            if (!$payload = $this->jwtManager->decode($preAuthToken)) {
                throw new InvalidTokenException('Invalid JWT Token');
            }

            $preAuthToken->setPayload($payload);
        } catch (JWTDecodeFailureException $e) {
            if (JWTDecodeFailureException::EXPIRED_TOKEN === $e->getReason()) {
                throw new ExpiredTokenException();
            }

            throw new InvalidTokenException('Invalid JWT Token', 0, $e);
        }

        return $preAuthToken;
    }
1005351
public function getOAuthAction(Request $request)
	{
		$this->initSession($request);

		$apiKeys = $this->getAppParams();

		$oauth = new \OAuth($apiKeys["api-key"], $apiKeys["api-secret"]);

		$tokens = $oauth->getRequestToken($this->getRequestTokenUrl(), $this->getCallbackUrl($request));
		$this->sessionBag->set("oauth_token", $tokens["oauth_token"]);
		$this->sessionBag->set("oauth_token_secret", $tokens["oauth_token_secret"]);

		return $this->redirect(
			$this->getAuthenticateUrl($tokens["oauth_token"])
// 			302,
// 			["Authorization" => $oauth->getRequestHeader("POST", $this->getRequestTokenUrl())]
		);
	}
378445
protected function getCredentials(Request $request)
    {
        $credentials = $request->only($this->loginUsername(), 'password');
        
        return array_merge($credentials, ['site_id' => site()->getCurrent()->id]);
    }
335648
public function postLogin(Request $request)
    {
        $this->loginValidator($request->all())->validate();

        $credentials = $request->only([$this->username(), 'password']);
        $remember = $request->get('remember', false);

        if ($this->guard()->attempt($credentials, $remember)) {
            return $this->sendLoginResponse($request);
        }

        return back()->withInput()->withErrors([
            $this->username() => $this->getFailedLoginMessage(),
        ]);
    }
1082912
public function supports(Request $request)
    {
        $post = json_decode($request->getContent(), true);

        return !empty($post[self::TOKEN_FIELD]);
    }
337206
public function authorizeFormSubmit(Request $request)
    {
        $user = $this->getUserFromRequest($request);

        if (! $user) {
            return $this->createInvalidCredentialResponse();
        }

        $attemptedPassword = $request->get('password');
        $hashedPassword    = $user->getPassword();

        $correctPassword = $this->verifyPassword($attemptedPassword, $hashedPassword);

        if (! $correctPassword) {
            return $this->createInvalidCredentialResponse();
        }

        // Automatically authorize the user
        $authorized = true;

        // The OAuth2 library assumes variables as GET params, but for security purposes they are POST. Convert here.
        $requestData = ($request->getMethod() === 'GET') ? $request->query : $request->request;

        $oauthRequest  = new OAuthRequest($requestData->all());
        $oauthResponse = new BridgeResponse();

        $response = $this->server->handleAuthorizeRequest(
            $oauthRequest,
            $oauthResponse,
            $authorized,
            $user->getId()
        );

        return $response;
    }
1057685
public function post(Request $request)
    {
        $id    = $request->attributes->get('id');
        $token = Arr::get($this->getContentAsArray($request), 'token');

        if (! $token) {
            return $this->createSimpleResponse(422, 'Token not specified.');
        }

        $conditions = [
            'user_id'       => $id,
            'token'         => $token,
            'token_type_id' => TokenEntity::TYPE_VERIFY_REGISTRATION,
        ];

        $token = $this->userService->findTokenBy($conditions);

        if (! $token) {
            return $this->createNotFoundResponse();
        }

        try {
            $user = $this->userService->verifyRegistration($token);
        } catch (OutOfBoundsException $e) {
            $httpCodes = [
                UserService::INCORRECT_TOKEN_TYPE => 422,
                UserService::TOKEN_EXPIRED        => 410,
                UserService::TOKEN_NOT_FOUND      => 404,
            ];

            return $this->createErrorResponse(
                ['token' => ['INVALID']],
                $httpCodes[$e->getCode()]
            );
        }

        $user = $user->getArrayCopy();

        unset($user['password']);

        return $user;
    }
929670
public function getOAuthCallbackAction(Request $request)
	{
		$this->initSessionBag();

		$apiKeys = $this->getAppParams();
		$oauth = new \OAuth($apiKeys["api-key"], $apiKeys["api-secret"]);
		$oauth->setToken($this->sessionBag->get("oauth_token"), $this->sessionBag->get("oauth_token_secret"));

		$oauthResponse = $oauth->getAccessToken($this->getAccessTokenUrl(), null, $request->query->get("oauth_verifier"));

		$this->storeOAuthData($oauthResponse);
		return $this->returnResult($oauthResponse);
	}
107330
protected function getTokenViaCookie($request)
    {
        // If we need to retrieve the token from the cookie, it'll be encrypted so we must
        // first decrypt the cookie and then attempt to find the token value within the
        // database. If we can't decrypt the value we'll bail out with a null return.
        try {
            $token = $this->decodeJwtTokenCookie($request);
        } catch (Exception $e) {
            return;
        }

        // We will compare the CSRF token in the decoded API token against the CSRF header
        // sent with the request. If they don't match then this request isn't sent from
        // a valid source and we won't authenticate the request for further handling.
        if (! Passport::$ignoreCsrfToken && (! $this->validCsrf($token, $request) ||
            time() >= $token['expiry'])) {
            return;
        }

        return $token;
    }
845974
public function supportRequestToken(Request $request)
    {
        $client = $request->getUser() && $request->getPassword();
        $token = 'refresh_token' == $request->get('grant_type') && $request->get('refresh_token');

        return $client && $token;
    }
1074079
public function authenticate(Request $request)
    {
        $email    = $request->input(self::AUTH_PARAM_EMAIL, null);
        $password = $request->input(self::AUTH_PARAM_PASSWORD, null);

        if ($email !== null &&
            $password !== null &&
            ($user = User::query()->where(User::FIELD_EMAIL, '=', strtolower($email))->first()) !== null
        ) {
            /** @var HasherInterface $hasher */
            $hasher = app(HasherInterface::class);
            if ($hasher->check($password, $user->{User::FIELD_PASSWORD_HASH}) === true) {
                /** @var TokenCodecInterface $codec */
                $codec = app(TokenCodecInterface::class);
                $token = $codec->encode($user);

                $this->getLogger()->debug(
                    'Account login success.',
                    [User::FIELD_EMAIL => $email, User::FIELD_ID => $user->getKey()]
                );

                return response($token);
            }
        }

        $this->getLogger()->debug('Account login failed.', [User::FIELD_EMAIL => $email]);

        return response(null, Response::HTTP_UNAUTHORIZED);
    }
1316464
public function passwordAction(Request $request)
    {
        $token = $this->get('request_stack')->getCurrentRequest()->get('token');
        if (!$token) {
            return $this->render('FOMUserBundle:Login:error-notoken.html.twig');
        }

        $user = $this->getDoctrine()->getRepository("FOMUserBundle:User")->findOneByResetToken($token);
        if (!$user) {
            $mail = $this->container->getParameter('fom_user.mail_from_address');
            return $this->render('FOMUserBundle:Login:error-notoken.html.twig', array(
                'site_email' => $mail));
        }

        $max_token_age = $this->container->getParameter("fom_user.max_reset_time");
        if (!$this->checkTimeInterval($user->getResetTime(), $max_token_age)) {
            $form = $this->createForm('form');
            return $this->render('FOMUserBundle:Login:error-tokenexpired.html.twig', array(
                'user' => $user,
                'form' => $form->createView()
            ));
        }

        $form = $this->createForm(new UserResetPassType(), $user)->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $user->setResetToken(null);

            $helper = new UserHelper($this->container);
            $helper->setPassword($user, $user->getPassword());

            $em->flush();

            return $this->redirect($this->generateUrl('fom_user_password_done'));
        }

        return array(
            'user' => $user,
            'form' => $form->createView());
    }