bain3 / pronotepy

A python API wrapper for pronote
MIT License
190 stars 53 forks source link

QRcode authentification #299

Closed Aldarande closed 1 month ago

Aldarande commented 3 months ago

Hi,

If i use the right pin and all data from my QRcode : {"jeton":"A08735EF309A6C557D078281EE20FB74CCF886262FC944C73FF77312EF3CE72CC77B9DF0CEC16C84890BD34A0CFF009C4DC842951DF873A35XXXXXX189CA050F302C4CD0F9C9F8B64B44B4A95F82CB196C71CFE1254F416D8B54D4CAB8E1385C430A29BBC07EE0A13374408D7609EA90","login":"4C0B20E070291XXXXX6452F80138CBE","url":"https://0912X09y.index-education.net/pronote/parent.html?identifiant=RPJ72raA9kEAXuvh#/mobile.parent.html"}

I have an issue :"('Decryption failed while trying to un pad. (probably bad decryption key/iv)', 'exception happened during login -> probably the qr code has expired (qr code is valid during 10 minutes)')"

But if i use url like that : https://0912X09y.index-education.net/pronote/mobile.parent.html I'm able to login

Do i left something ?

bain3 commented 3 months ago

Hi, interesting. So what you're saying is that when you change the url field in the data to the correct looking one, then it works? That original url field in the data looks suspicious.

Aldarande commented 3 months ago

Yes exactly 👍 for exemple QRCode url : https://0912109y.index-education.net/pronote/mobile.parent.html?bydlg=A6ABB224-12DD-4E31-AD3E-8A39A1C2C335&login=true Login failed but if i change it for : https://0912109y.index-education.net/pronote/mobile.parent.html I'm able to use qrcode_login correctly.

bain3 commented 3 months ago

Looks like the url was being formed incorrectly. Could you try the fix? You can install the latest version with:

pip install -U git+https://github.com/bain3/pronotepy
Aldarande commented 3 months ago

Good evening,

So I did the test: but the url generated in the qr code this time is : https://0912109y.index-education.net/pronote/parent.html?identifiant=fQu3eqVqTyKF6Acx#/mobile.parent.html

So it's normal that it doesn't match. For info I added this to my python code:

# I clean up the URL

    base_url = url.split("/pronote/")[0] + "/pronote/"

    last_part = url.split("mobile.")[-1]
    last_part = (
        "mobile." + last_part.split("#")[-1]
    )  
    cleaned_url = base_url + last_part
bain3 commented 2 months ago

Ok I think this is it. I basically did the thing you suggested. The mobile app does a lot of unnecessary work in my opinion.

Could you please try the fix again?

Aldarande commented 2 months ago

Hi, i have just made the test, but it doesn't work. the login failed.

bain3 commented 2 months ago

I am sorry this is taking so long. This is weird though. When I test the code with your URL, it correctly transforms it to the one that you say works (previous comment). Are you sure you updated your installed pronotepy?

It might be because I left the fragment in the url, fixed it. I can't think of anything else that could be wrong now.

bain3 commented 2 months ago

Thank you for your patience.

Aldarande commented 2 months ago

It's the same without my code who cleaning url, it's doesn't work. Url from GR code : https://0912109y.index-education.net/pronote/mobile.parent.html?fd=1&bydlg=A6ABB224-12DD-4E31-AD3E-8A39A1C2C335&login=true my url cleaned : https://0912109y.index-education.net/pronote/mobile.parent.html

Let me check another, but i feel i don't have the patch because i using : pip3 install pronotepy

bain3 commented 1 month ago

I am quite certain that you just did not install the git version, so I consider this as fixed. You can get the latest version (v2.13.1) from pypi.