node-chatgpt-api icon indicating copy to clipboard operation
node-chatgpt-api copied to clipboard

Suddenly Wouldn't work, And this is returned after I enabled debug mode: ClientSecretCredential authentication failed

Open BarryAllen-Arrow opened this issue 1 year ago • 2 comments

Unhandled Exception ---> ClientSecretCredential authentication failed: A configuration issue is preventing authentication - check the error message from the server for details. You can modify the configuration in the application registration portal. See https://aka.ms/msal-net-invalid-client for details. Original exception: AADSTS7000222: The provided client secret keys for app 'f8742d71-a9af-4291-a6e3-8f225540a102' are expired. Visit the Azure portal to create new keys for your app: https://aka.ms/NewClientSecret, or consider using certificate credentials for added security: https://aka.ms/certCreds. Trace ID: da3e8f98-afef-4a1f-ac5c-a65effd34500 Correlation ID: 257666b4-e90a-479b-8882-cf13f0a6c724 Timestamp: 2023-10-29 15:31:00Z

seems like an authentication problem...but I'm very sure my cookies are valid, the program just suddenly broke when the last question is handled pretty well

BarryAllen-Arrow avatar Oct 29 '23 15:10 BarryAllen-Arrow

it's now returning this: "BingProdUnAuthenticatedUsers{ conversationId: '51D|BingProdUnAuthenticatedUsers|39F9FF0BE4991082BC0CB9F6B16017A6E07229C4B42E7FBD44A470EC08516B00', clientId: '1055518422899228', result: { value: 'Success', message: null } }"

BarryAllen-Arrow avatar Oct 29 '23 15:10 BarryAllen-Arrow

Confirmed.

async (req, res) => {
        try {
            const { message, _U } = req.body;
            const typeVariant = req.typeVariant || 'Creative';
            const options = {
                // Necessary for some people in different countries, e.g. China (https://cn.bing.com)

                // "_U" cookie from bing.com
                userToken: _U || process.env.BING_COOKIE,
                // If the above doesn't work, provide all your cookies as a string instead

                // A proxy string like "http://<ip>:<port>"
                // (Optional) Set to true to enable `console.debug()` logging
                debug: true,
            };
            const cacheOptions = {
                // Options for the Keyv cache, see https://www.npmjs.com/package/keyv
                // This is used for storing conversations, and supports additional drivers (conversations are stored in memory by default)
                // For example, to use a JSON file (`npm i keyv-file`) as a database:
                store: new Map(),
            };
            const sydneyAIClient = new BingAIClient({
                ...options,
                cache: cacheOptions,
            });
            let jailbreakResponse = await sydneyAIClient.sendMessage(message, {
                jailbreakConversationId: true,
                onProgress: (token) => {
                    process.stdout.write(token);
                },
            });

            console.log(jailbreakResponse);

            // const response = await api.sendMessage(message,
            //     { locale: 'tr-TR', market: 'tr-TR', region: 'TR', variant: typeVariant });
            res.json({ text: jailbreakResponse.response });
        } catch (error) {
            console.log(error);
            res.status(500).json({ error: 'Sunucu hatası' });
        }
    }

Result:

Server is running
{
  conversationId: '51D|BingProdUnAuthenticatedUsers|7F7B3B5AE4E3A354237C1D1A069533DBFCD5A2401F091B23148499C1996278F5',
  clientId: '985157174939315',
  result: { value: 'Success', message: null }
}
Success: null
    at BingAIClient.sendMessage (file:///home/sammy/node_modules/@waylaidwanderer/chatgpt-api/src/BingAIClient.js:231:31)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async file:///home/sammy/routes/bingRoutes.js:150:37

I'm using a valid _U cookie. I also tried after adding all the cookies. Again the result is the same.

MahmutHizal avatar Dec 10 '23 16:12 MahmutHizal