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

An error occured: OpenaiChat: MissingAuthError: Add a "api_key" or a .har file #2092

Open
hodhh8 opened this issue Jul 3, 2024 · 82 comments
Assignees
Labels
bug Something isn't working stale

Comments

@hodhh8
Copy link

hodhh8 commented Jul 3, 2024

Screenshot 2024-07-03 210708

@hodhh8 hodhh8 added the bug Something isn't working label Jul 3, 2024
@gamelist1990
Copy link
Contributor

gamelist1990 commented Jul 4, 2024

Have you added chatgpt.com.har?

@Anurag-Varma
Copy link
Contributor

Not a bug,

Need to use api key or use a .har file with the cookies from the chatgpt website and keep it in the har_and_cookies folder

@imranaalam
Copy link

i was hoping can there be a chrome extension be made that can fetch har and integrate with gpt4free

@gamelist1990
Copy link
Contributor

I think it's difficult to get it with an extension.
@imranaalam

@dabatz
Copy link

dabatz commented Jul 5, 2024

how can it be fixed then? becuase i dont know how to add the .har file and where. could somone provide a more detailed explenation on how to do it?

@gamelist1990
Copy link
Contributor

gamelist1990 commented Jul 5, 2024

Obtaining the HAR file from ChatGPT

Here's a method to obtain the HAR (HTTP Archive) file from ChatGPT:

  1. Access ChatGPT: Go to https://chatgpt.com/.
  2. Open Network Tab: Open your browser's developer tools and navigate to the "Network" tab.
  3. Send a Request: Interact with the AI by sending a message. Ensure you see a response in the Network tab, indicating a successful request.
  4. Open New Chat: Click on "New Chat" to start a fresh conversation.
  5. Check Request Count: Observe the request count in the Network tab. If successful, the count should be approximately between 93 and 104.

At this point, you can right-click on any of the requests and select "Save as HAR" to download the HAR file.

Note: The exact request count may vary slightly depending on the specific interaction and browser used.

@dabatz
Copy link

dabatz commented Jul 5, 2024

@gamelist1990 I did all the steps but it still sends the same error. I downloaded the har file (as "chatgpt.com") and put it in the same directory as the g4f file (C:\Users\user\Downloads\coding related stuff\g4f.exe). did I do something wrong?

P.S. Thanks for the help. Appreciate it.

@Anurag-Varma
Copy link
Contributor

Anurag-Varma commented Jul 5, 2024

If u downloaded the github repo, you can keep it in the har_and_cookies folder.

Dont know where to keep incase of g4f.exe

@dabatz
Copy link

dabatz commented Jul 5, 2024

I don't have a har_and_cookies folder, should I create one in the g4f directory?

@dabatz
Copy link

dabatz commented Jul 5, 2024

ok, I now downloaded it correctly, I think, using "pip install g4f" in cmd. is that ok? if yes what do I do now?

@gamelist1990
Copy link
Contributor

gamelist1990 commented Jul 5, 2024

image
I have specified the directory to put the har files in, so it is the har folder, but you can create a separate har_and_cookies folder and put the created har files in that folder. 

cookies_dir = os.path.join(os.path.dirname(file), "har_and_cookies")
set_cookies_dir(cookies_dir)
read_cookie_files(cookies_dir)

@dabatz

@gamelist1990
Copy link
Contributor

@dabatz

What should I do in the case of g4f.exe? It doesn't change, but g4f.exe seems to just be running flask internally, so place g4f.exe and the har_and_cookies folder in the directory and put the har file in it.

@Lorodn4x
Copy link

Lorodn4x commented Jul 6, 2024

Hello,
I am using a VPN through WireGuard and it seems that this might be causing an issue with authentication. I have followed all the steps to add the .har file, but the "MissingAuthError: Add a 'api_key' or a .har file" error still appears. Could you please advise what can be done in this situation?
Thank you.

@iG8R
Copy link

iG8R commented Jul 6, 2024

@Lorodn4x
Hello.
No, it doesn't depend on using a VPN, because even without a VPN this problem still exists.

@Lorodn4x
Copy link

Lorodn4x commented Jul 6, 2024

@iG8R Thank you for your response. In my country, ChatGPT does not work without a VPN. Even when I follow all the steps using the VPN, I occasionally receive messages stating that the service is not available in my region or something similar. I have encountered this error again and attached a screenshot for further clarification
Снимок экрана 2024-07-06 233429

@iG8R
Copy link

iG8R commented Jul 6, 2024

@Lorodn4x
In my country, ChatGPT works fine without VPN, but g4f still gets the error mentioned in this issue.

@gamelist1990
Copy link
Contributor

Could you please provide the code you're using and where you put the har?

@iG8R
@Lorodn4x

@iG8R
Copy link

iG8R commented Jul 7, 2024

@gamelist1990
Many thanks for your attention and concern.

image

@iG8R
Copy link

iG8R commented Jul 7, 2024

Also I used your last PR fea9e7a

@gamelist1990
Copy link
Contributor

It looks like Arkose authentication has passed, but then a 502 error appears

For now, if you get a 502 error even after trying several times, try changing the model to auto or something similar. I use the auto model.

@gamelist1990
Copy link
Contributor

Also I used your last PR fea9e7a

That fix solved the Arkose issue so it's fine.

@iG8R
Copy link

iG8R commented Jul 7, 2024

As you can see, not every time I got a 502 error, sometimes there is a "No arkose token found in .har file" error and sometimes there is an "OK" response.

@gamelist1990
Copy link
Contributor

Can you try the model with auto?

@iG8R
Copy link

iG8R commented Jul 7, 2024

image

@gamelist1990
Copy link
Contributor

Umm

@iG8R
Copy link

iG8R commented Jul 7, 2024

I use the following app and browser extension to make a request to g4f #1896 (comment)

@gamelist1990
Copy link
Contributor

I'll take a look.

@gamelist1990
Copy link
Contributor

https://tcr9i.chat.openai.com/fc/gt2/public_key/35536E1E-65B4-4D96-9D97-6ADB7EFF8147 is no longer in use, so this is just a guess, but Arkose is definitely no longer in use.

@gamelist1990
Copy link
Contributor

By the way, I tried to fix that just now, but it failed spectacularly (^^)

Copy link

Bumping this issue because it has been open for 7 days with no activity. Closing automatically in 7 days unless it becomes active again.

@github-actions github-actions bot added the stale label Jul 18, 2024
@iG8R
Copy link

iG8R commented Jul 18, 2024

up

@github-actions github-actions bot removed the stale label Jul 19, 2024
@vi-vlasov
Copy link

Copy link

Bumping this issue because it has been open for 7 days with no activity. Closing automatically in 7 days unless it becomes active again.

@github-actions github-actions bot added the stale label Jul 31, 2024
@iG8R
Copy link

iG8R commented Jul 31, 2024

up

@github-actions github-actions bot removed the stale label Aug 1, 2024
Copy link

github-actions bot commented Aug 9, 2024

Bumping this issue because it has been open for 7 days with no activity. Closing automatically in 7 days unless it becomes active again.

@github-actions github-actions bot added stale and removed stale labels Aug 9, 2024
Copy link

Bumping this issue because it has been open for 7 days with no activity. Closing automatically in 7 days unless it becomes active again.

@github-actions github-actions bot added the stale label Aug 22, 2024
@iG8R
Copy link

iG8R commented Aug 22, 2024

up

@github-actions github-actions bot removed the stale label Aug 23, 2024
Copy link

Bumping this issue because it has been open for 7 days with no activity. Closing automatically in 7 days unless it becomes active again.

@github-actions github-actions bot added the stale label Aug 30, 2024
@deAladin
Copy link

deAladin commented Sep 5, 2024

I think this issue is fixed now?

@iG8R
Copy link

iG8R commented Sep 5, 2024

No.

@github-actions github-actions bot removed the stale label Sep 6, 2024
@tmcnairbledsoe
Copy link

I also am having this issue. I am in the us, I get the har file and post it and run this code before the issue arises. Any advice for even a workaround?

from g4f.client import Client
import os.path
from g4f.cookies import set_cookies_dir, read_cookie_files
from g4f.Provider import (OpenaiChat)

import g4f.debug
g4f.debug.logging = True
cookies_dir = os.path.join(os.path.dirname(file), "har_and_cookies")
set_cookies_dir(cookies_dir)
read_cookie_files(cookies_dir)

client = Client(provider=OpenaiChat)
response = client.chat.completions.create(
model=g4f.models.gpt_4,
messages=[{"role": "user", "content": "Hello"}],
)
print(response.choices[0].message.content)

@gamelist1990
Copy link
Contributor

@tmcnairbledsoe @iG8R @dabatz We found that the current OpenAI certification uses Bearer certification

@iG8R
Copy link

iG8R commented Sep 10, 2024

@gamelist1990
Will this info help solve the "MissingAuthError" issue mentioned in the title?

Copy link

Bumping this issue because it has been open for 7 days with no activity. Closing automatically in 7 days unless it becomes active again.

@github-actions github-actions bot added the stale label Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stale
Projects
None yet
Development

No branches or pull requests