Aedial / novelai-api

Python API for the NovelAI REST API
https://aedial.github.io/novelai-api/
MIT License
129 stars 17 forks source link

Unable to log in with email and password #36

Closed Awakumori closed 1 month ago

Awakumori commented 1 month ago

Hello,

I tried logging in with my email and password, and it worked successfully when I used python -m novelai_api access_key. However, when I used the same email and password with python -m novelai_api access_token, it always failed, returning the error novelai_api.NovelAIError.NovelAIError: https://api.novelai.net/user/login (401) - Incorrect access key.

This confuses me a lot: I used the same email and password, but got completely different results.

Please check the image attached.

2024-09-01 011107

2024-09-01 011204

Aedial commented 1 month ago

So, there are 2 things : access key and access token.

As such, you need to get the access key then use the login endpoint to get the access token from the access key (see https://github.com/Aedial/novelai-api/blob/main/novelai_api/_high_level.py#L61). From what I can see, you're trying to use your email to get the access token.

Awakumori commented 1 month ago

Thank you for your reply. In your reply, you pointed out that I should not use email to get the access token. However, I followed the instructions in the README file. According to the README file, getting the access token and getting the access key use the same parameters, i.e. [username,password]. Please check the image. 2024-09-03 010541 2024-09-03 010557

Aedial commented 1 month ago

Yes, indeed. Been a while I used these and I forgot. It's indeed login and password.

If your password contains special characters (like '\'), you might need to escape them, because of the terminal. This is, however, not an issue when calling the login from code itself, it's a terminal quirk.