PawanOsman / GoogleBard

GoogleBard - A reverse engineered API for Google Bard chatbot for NodeJS
https://bard.google.com
MIT License
415 stars 57 forks source link

Have issues requesting a prompt #12

Closed mashwishi closed 1 year ago

mashwishi commented 1 year ago
import express from 'express';
import * as dotenv from 'dotenv';
import cors from 'cors';
import { Bard } from "googlebard";

dotenv.config();

const app = express();
app.use(cors());
app.use(express.json());

app.get('/', async (req, res) => {
  res.status(200).send({
    message: '- Last Update May 17, 2023',
  })
});

app.post('/', async (req, res) => {

  try {

    const prompt = req.body.prompt;

    let cookies = `__Secure-1PSID=<i insert my token here>`;

    let bot = new Bard(cookies);

    let response = await bot.ask(prompt);
    console.log(response);

    res.status(200).send({
      bot: response
    });

  } catch (error) {
    res.status(500).send(error || 'Something went wrong, please try again.');
  }

})

app.listen(5500, () => console.log('Started on port 5500'))

Where i get the key? Inside this..

image

Sample json request:

{
  "prompt": "Hello"
}

Error:

image

Using proxy doesn't make any sense if the token you got is whitelisted and also i am able to use bard even i am not in US without using VPN.

mashwishi commented 1 year ago

@PawanOsman So i found this issue when you have multiple logged in account in your browser. I would suggest to add in readme on which account they are using if they are using the main account make sure to use the number example if it is 3rd logged in account you will notice it in the URL:

image

That's why instead of using the 1PSID use the number same number as the account..

image

But the best thing here is logging in the a browser with ONLY whitelisted account.

LautaroFranc commented 1 year ago

thank you so much

mehul-srivastava commented 1 year ago

Hi @PawanOsman! I have created a PR #15 corresponding to this issue. Could you please have a look at it?

MrlolDev commented 1 year ago

Having same issues with just one account , tried 1PSID and 3PSID, any assistance please?

mehul-srivastava commented 1 year ago

Having same issues with just one account , tried 1PSID and 3PSID, any assistance please?

Can you share the snippet of your code here?