@param string $audience

@return \CosmonovaRnD\JWT\Token\Builder
481648
public function addAudience(string $audience): Builder
    {
        $audiences = $this->claims[Claims::AUDIENCE] ?? [];

        if (!\in_array($audience, $audiences)) {
            $audiences[] = $audience;
        }

        $this->claims[Claims::AUDIENCE] = $audiences;

        return $this;
    }
470995
public function create($data, $token = null)
    {
        if (isset($token)) {
            return $this->client()->put($data, 'password-tokens/{token}', ['token' => $token]);
        }

        return $this->client()->post($data, 'password-tokens');
    }
27415
public function setConsumerAndToken(OAuthConsumer $consumer, OAuthConsumer $token)
    {
        $this->consumer = $consumer;
        $this->token = $token;
        return $this;
    }
146568
public static function factory($config = array())
	{
		$default = array();
		$required = array('base_url');
		$config = Inspector::prepareConfig($config, $default, $required);
		$client = new self($config->get('base_url'), $config->get('token'));
		$client->setConfig($config);
		$client->getEventDispatcher()->addSubscriber(new AuthenticationObserver());
		return $client;
	}
1202003
public function setToken($token)
    {
        $this->token = $token;
        $this->username = '';
        $this->password = '';
        $this->accessToken = '';
        return $this;
    }
475376
public function authenticatedChannel($token = null)
    {
        $token = $this->getToken($token);

        $channelAPI = new Channels($token);

        return $channelAPI->authenticatedChannel();
    }
793476
public static function fromString(string $token): self
    {
        $instance = new self();
        $instance->token = $token;

        $parsed = explode('.', $token);
        if (count($parsed) !== 3) {
            throw new InvalidArgumentException('PbjxToken string is invalid.');
        }

        $instance->header = json_decode(self::urlsafeB64Decode($parsed[0]), true);
        $instance->payload = json_decode(self::urlsafeB64Decode($parsed[1]), true);
        $instance->signature = self::urlsafeB64Decode($parsed[2]);
        $instance->checkClaims();

        $instance->payload['exp'] = (int)$instance->payload['exp'];
        $instance->payload['iat'] = (int)$instance->payload['iat'];

        return $instance;
    }
3992
public static function createMessageEchoEvent(array $payload)
    {
        $message = MessageEcho::create($payload['message']);
        $senderId = $payload['sender']['id'];
        $recipientId = $payload['recipient']['id'];
        $timestamp = $payload['timestamp'];

        return new MessageEchoEvent($senderId, $recipientId, $timestamp, $message);
    }
1139871
private function _GrpcStreamUnary($channel)
    {
        return function ($method,
                         $deserialize,
                         array $metadata = [],
                         array $options = []) use ($channel) {
            $call = $this->call_invoker->ClientStreamingCall(
                $channel,
                $method,
                $deserialize,
                $options
            );
            $jwt_aud_uri = $this->_get_jwt_aud_uri($method);
            if (is_callable($this->update_metadata)) {
                $metadata = call_user_func(
                    $this->update_metadata,
                    $metadata,
                    $jwt_aud_uri
                );
            }
            $metadata = $this->_validate_and_normalize_metadata(
                $metadata
            );
            $call->start($metadata);
            return $call;
        };
    }
1196989
public function decodeJWT($encToken)
    {
        $config = [
            // The api_identifier setting could come through as an array or a string.
            'valid_audiences' => is_array($this->api_identifier) ? $this->api_identifier : [$this->api_identifier],
            'client_secret' => $this->api_secret,
            'authorized_iss' => [$this->authorized_issuer],
            'supported_algs' => $this->supported_algs,
            'secret_base64_encoded' => $this->secret_base64_encoded
        ];

        if (null !== $this->cache) {
            $config['cache'] = $this->cache;
        }

        $verifier = new JWTVerifier($config);

        return $verifier->verifyAndDecode($encToken);
    }
471790
public function getDecodedToken(string $jwt)
    {
        try {
            /** @noinspection PhpUnusedLocalVariableInspection */
            [$headb64, $bodyb64, $cryptob64] = \explode('.', $jwt);
            $decodedToken = \json_decode(JWT::urlsafeB64Decode($bodyb64));

            /** @noinspection NullPointerExceptionInspection */
            JWT::decode($jwt, $this->findTenant($decodedToken->iss)->getSharedSecret(), ['HS256']);

            return $decodedToken;
        } catch (\Throwable $e) {
            throw new AuthenticationException($e->getMessage());
        }
    }
662482
protected function requireToken($token)
    {
        if ($token) {
            return $this->setToken($token);
        } elseif ($this->token) {
            return $this;
        } else {
            throw new JWTException('A token is required', 400);
        }
    }
1145649
public function setIdToken($idToken)
    {
        $jwtVerifier          = new JWTVerifier([
            'valid_audiences' => ! empty($this->idTokenAud) ? $this->idTokenAud : [ $this->clientId ],
            'supported_algs' => $this->idTokenAlg ? [ $this->idTokenAlg ] : [ 'HS256', 'RS256' ],
            'authorized_iss' => $this->idTokenIss ? $this->idTokenIss : [ 'https://'.$this->domain.'/' ],
            'client_secret' => $this->clientSecret,
            'secret_base64_encoded' => $this->clientSecretEncoded,
            'guzzle_options' => $this->guzzleOptions,
        ]);
        $this->idTokenDecoded = (array) $jwtVerifier->verifyAndDecode( $idToken );

        if (in_array('id_token', $this->persistantMap)) {
            $this->store->set('id_token', $idToken);
        }

        $this->idToken = $idToken;
        return $this;
    }
461410
public function buildProvider($provider, $config)
    {
        $provider = new $provider(
            $this->app['request'], $config['client_id'],
            $config['client_secret'], $config['redirect_uri']
        );

        $provider->setBaseURL($config['tokenpass_url']);

        return $provider;
    }
434770
public function create($listener)
    {
        $model = new Fluent([
            'site' => ['name' => \config('app.name', 'Orchestra Platform')],
        ]);

        $form = $this->presenter->form($model);

        return $listener->createSucceed(\compact('form', 'model'));
    }
1092759
public function create($message): BroadcastResponse
    {
        $message = $this->isValidMessage($message);

        $request = new BroadcastRequest($this->pageToken, $message);
        $response = $this->client->post('me/message_creatives', $request->build());

        return new BroadcastResponse($response);
    }
680322
public function requestToken(Request $request)
    {
        $client = $this->getClient($request);
        $refreshToken = $request->get('refresh_token');

        /** @var TokenInterface $accessToken */
        $accessToken = $this->accessTokenRepository->findOneByClientAndRefreshToken($client, $refreshToken);

        if (! $accessToken instanceof TokenInterface) {
            throw new TokenNotFoundHttpException();
        }
        if ($accessToken->isBlocked()) {
            throw new TokenBlockedHttpException();
        }

        $newAccessToken = $this->accessTokenManager->create($client, $accessToken->getUser());
        if (!$newAccessToken->isValid($this->validator)) {
            return $newAccessToken->getViolations();
        }

        $this->accessTokenManager->save($newAccessToken);

        $tokenFacade = new AccessTokenFacade();
        $tokenFacade->accessToken   = $newAccessToken->getCode();
        $tokenFacade->expiresAt     = $newAccessToken->getExpiredAt();
        $tokenFacade->refreshToken = $newAccessToken->getRefreshCode();

        return $tokenFacade;
    }