@param string              $providerKey
@param array               $attributes
@param mixed               $user
@param SamlSpResponseToken $responseToken

@return TokenInterface
180486
public function create($providerKey, array $attributes, $user, SamlSpResponseToken $responseToken)
    {
        $token = new SamlSpToken(
            $user instanceof UserInterface ? $user->getRoles() : [],
            $providerKey,
            $attributes,
            $user
        );

        return $token;
    }
197819
public function createToken(Request $request, $providerKey)
    {
        $apiKey = $request->headers->get($this->header);

        if (!$apiKey) {
            throw new BadCredentialsException('No ApiKey found in request!');
        }

        return new PreAuthenticatedToken(
            'unauthorized',
            $apiKey,
            $providerKey
        );
    }
513793
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
    {
        $user = $token->getUser();

        if (!$user instanceof UserInterface) {
            return false;
        }

        $groupable = $subject;

        switch ($attribute) {
            case self::VIEW:
                return $this->canView($groupable, $token);
            case self::EDIT:
                return $this->canEdit($groupable, $token);
        }
    }
32072
public function createNew(
        string $providerName,
        string $credentialPubKey,
        string $accessToken,
        string $tokenSecret = '',
        string $signupHash = ''
    ) : array {

        $array = [
            'provider'     => $providerName,
            'access_token' => $accessToken,
            'credential'   => $credentialPubKey
        ];

        if (! empty($tokenSecret)) {
            $array['token_secret'] = $tokenSecret;
        }

        if (! empty($signupHash)) {
            $array['signup_hash'] = $signupHash;
        }

        return $this->sendPost(
            '/sso',
            [],
            $array
        );
    }
486284
public function provider(ProviderRequest $providerRequest)
    {
      // Extract SimplePay user from request
      $user = $providerRequest->getUser();

      // Create request
      $request = new StdClass();
      $request->User = new StdClass();
      $request->User->Uuid = $user->getUuid()->getValue();
      $request->User->Hash = $user->getHash();

      /*$request = new StdClass();
       $request->Auth = new StdClass();
       $request->Auth->Uuid
       $request->Auth->Method
       $request->Auth->Signature
       $request->Auth->Token
       $request->Auth->Timestamp
       $request->Auth->Nonce
       $request->Auth->Version*/

      // Check type
      if($providerRequest->hasType())
        $request->Type = $providerRequest->getType();

      // Send request
      $response = $this->getSoapClient()->provider($request);

      // Create a new ProviderResponse
      $providerResponse = new ProviderResponse();

      if(!is_array($response->Provider))
        $response->Provider = array($response->Provider);

      foreach($response->Provider as $provider)
      {
        // Extract values from reponse
        $uuid = $provider->Uuid;
        $name = $provider->Name;
        $type = $provider->Type;

        $uuid = new Uuid($uuid);

        // Create a new Provider
        $provider = new Provider($uuid, $name, $type);

        // Add bank to response
        $providerResponse->addProvider($provider);
      }

      return $providerResponse;
    }
1159843
User getUser(String id, AccessToken accessToken, String... attributes) {
        return getResource(id, accessToken, attributes);
    }
149292
public function getUser($credentials, UserProviderInterface $userProvider): ?UserInterface
    {
        $token = $this->userProvider->getDecodedToken($credentials['jwt']);
        $clientKey = $token->iss;

        if (!$clientKey) {
            throw new AuthenticationException(
                \sprintf('API Key "%s" does not exist.', $credentials['jwt'])
            );
        }

        /** @var TenantInterface|UserInterface $user */
        $user = $this->userProvider->loadUserByUsername($clientKey);
        if (\property_exists($token, 'sub')) {
            // for some reasons, when webhooks are called - field sub is undefined
            $user->setUsername($token->sub);
        }

        return $user;
    }
1219058
protected function createKey($attributes, $user_id)
    {
        $model = new UserOauthKey;
        $model->provider_id = $attributes['provider_id'];
        $model->provider_user_id = (string) $attributes['provider_user_id'];
        $model->page = (string) $attributes['page'];
        $model->user_id = $user_id;
        return $model->save();
    }
415984
protected function createAuthCode($userkey, $applicationkey) {
        $payload = $userkey . "@" . strtolower($this->serverhostname) . "|" . strtolower($applicationkey);
        return strtoupper(sha1($payload));
    }
886385
public function enableAction(Request $request, $userClass)
    {
        $confirmationToken = $request->query->get('token');
        if (null === $confirmationToken) {
            return new JsonResponse(null, 404);
        }

        try {
            $this->get('bengor_user.' . $userClass . '.api_command_bus')->handle(
                new EnableUserCommand($confirmationToken)
            );

            return new JsonResponse();
        } catch (UserTokenNotFoundException $exception) {
            return new JsonResponse(
                sprintf(
                    'The "%s" confirmation token does not exist',
                    $confirmationToken
                ),
                400
            );
        }
    }
706627
protected function prepareTokenResponse(
        AccessToken $accessToken,
        RefreshToken $refreshToken = null,
        bool $useRefreshTokenScopes = false
    ): ResponseInterface {
        $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));
    }
163344
public function createToken(Request $request, $providerKey)
    {
        if (!$this->secret) {
            return null;
        }

        // look for an authorization header
        $authorizationHeader = $request->headers->get('Authorization');

        if ($authorizationHeader === null) {
            return null;
        }

        if (0 !== stripos($authorizationHeader, 'Bearer ')) {
            return null;
        }

        // extract the JWT
        $authToken = substr($authorizationHeader, 7);

        try {
            // decode and validate the JWT - will throw exceptions for various conditions.
            $token = $this->decodeToken($authToken);
        } catch (\Exception $exception) {
            return null;
        }

        return new JavascriptWebToken($token, $providerKey);
    }
1373972
public function createAuthenticationProvider(\Silex\Application $app,
                                                 UserProviderInterface $userProvider,
                                                 $providerKey)
    {
        return new DaoAuthenticationProvider($userProvider,
            $app['security.user_checker'], $providerKey,
            $this->encoderFactory ? : $app['security.encoder_factory']);
    }
980987
public function authenticateWithToken(TokenInterface $token, Request $request, string $providerKey = null)
    {
        $this->migrateSession($request, $token, $providerKey);
        $this->tokenStorage->setToken($token);

        if (null !== $this->dispatcher) {
            $loginEvent = new InteractiveLoginEvent($request, $token);
            $this->dispatcher->dispatch($loginEvent, SecurityEvents::INTERACTIVE_LOGIN);
        }
    }
824927
public function newTokenAction(Request $request, $userClass)
    {
        try {
            $this->get('bengor_user.' . $userClass . '.api_command_bus')->handle(
                new LogInUserCommand(
                    $request->getUser(),
                    $request->getPassword()
                )
            );
        } catch (UserDoesNotExistException $exception) {
            return new JsonResponse('', 400);
        } catch (UserEmailInvalidException $exception) {
            return new JsonResponse('', 400);
        } catch (UserInactiveException $exception) {
            return new JsonResponse('Inactive user', 400);
        } catch (UserPasswordInvalidException $exception) {
            return new JsonResponse('', 400);
        }
        $token = $this->get('lexik_jwt_authentication.encoder.default')->encode(['email' => $request->getUser()]);

        return new JsonResponse(['token' => $token]);
    }
38595
public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey)
    {
        $user = $token->getUser();

        $this->dispatcher->dispatch(self::OAUTH_LOGIN_SUCCESS, new UserEvent($user));

        return $this->authResponseService->authenticateResponse($user,
            new Response($this->twig->render('@StarterKitStart/oauth-success.html.twig')));
    }
602994
public function createApplicationToken($application, $privateKey)
    {
        $tokenRequest = $this->getTokenizer()->signTokenRequest(
            $this->getTokenizer()->createApplicationTokenRequest(
                $application
            ),
            $privateKey
        );

        $request = (new RequestDescriptor())
            ->setUrl($this->buildUrl('/api/token'))
            ->setMethod('POST');
        $request->setBodyParams([
            'token-request' => json_encode($tokenRequest->toArray())
        ]);

        try {
            return json_decode($this->send($request)->getBody(), true);
        } catch (\Exception $e) {
            $previous = $e->getPrevious();

            if ($previous instanceof BadResponseException) {
                $error = json_decode($previous->getResponse()->getBody(true), true);

                throw new TokenException($error['error'], $error['code'], $previous);
            }

            throw new TokenException($e->getMessage(), $e->getCode(), $e->getPrevious());
        }
    }