Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Couldn't send message: Couldn't get access token: failed to decode response: invalid character '<' looking for beginning of value #16

Open
NatsuNiNi opened this issue Feb 13, 2023 · 8 comments

Comments

@NatsuNiNi
Copy link

Starting the bot, I get this message as an answer to my hello msg

"Couldn't send message: Couldn't get access token: failed to decode response: invalid character '<' looking for beginning of value"

I searched for those issues before sending. But no help :(

Hope somebody can give me some help.

@wsimon98
Copy link

Same issue. Following to see if it gets fixed.

@Yousjjw
Copy link

Yousjjw commented Feb 26, 2023

when I try to install chatgpt-telegram , I received the same error .

@wsimon98
Copy link

it has to do with how ChatGPT fixed authentication. You have to authenticate through the API code. And If i read this code right, it's using a login and cookie to do the authenticating.

@Yousjjw
Copy link

Yousjjw commented Feb 28, 2023

Looking forward to some updates

@AleksandrPe
Copy link

Can someone tell me how to fix it?

@NatsuNiNi
Copy link
Author

Nah, till now I cant solve it :(

@jocull
Copy link

jocull commented Mar 4, 2023

Something with the authentication has changed I believe. Here is the relevant code:

accessToken, err := c.refreshAccessToken()
if err != nil {
return nil, errors.New(fmt.Sprintf("Couldn't get access token: %v", err))
}

which calls

req, err := http.NewRequest("GET", "https://chat.openai.com/api/auth/session", nil)
if err != nil {
return "", fmt.Errorf("failed to create request: %v", err)
}

When you make a request following this it seems to spit back some HTML, which explains the invalid <.

image

If I copy the complete cookie set out of my browser then I can make this request work as expected, but it seems like the __Secure-next-auth.session-token value is not enough on its own. Here's the complete cookie set the website currently manages:

image

If I had to guess, the CSRF token is relevant somehow. It could also be that I did my authentication step on one machine (desktop) but then moved the token to a separate machine (server).

Hope those details help someone 🙂

@jocull
Copy link

jocull commented Mar 4, 2023

On further inspection in a fresh browser session, I think this is a duplicate of #2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants