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);
    }