bain3 / pronotepy

A python API wrapper for pronote
MIT License
191 stars 55 forks source link

Add error codes in PRONOTE protocol.md #267

Open XibalbaM opened 1 year ago

XibalbaM commented 1 year ago

Hi ! I'm trying to make an equivalent to this lib in kotlin, but I'm struggling with "Identification" request. I can do "FonctionParametres" request without problems but with this one I can't achieve it. My json body is good, it matches the one used by the website. But I get an error: {"Erreur":{"G":14,"Titre":"La page a expir\u00E9 ! (7)","Message":""}} And I can't find why. That's why it could be good to add an explanation on errors in PRONOTE protocol.md

bain3 commented 1 year ago

I'd love to, but I have no idea what most of the error codes mean... The best I've got is this enum from eleve.js:

const EGenreErreurAcces = {
    Aucune: 0,
    Identification: 1,
    Autorisation: 2,
    ConnexionClasse: 3,
    AucuneRessource: 4,
    Connexion: 5,
    BloqueeEleve: 6,
    FonctionAccompagnant: 7,
    AccompagnantAucunEleve: 8,
    Message: 9,
    CompteDesactive: 10
};
XibalbaM commented 1 year ago

Okay thanks

OmegaMax commented 1 year ago

@XibalbaM We have the same problem too, for the fonction parametre there's no problem, but for Identification we get the same error. We don't know why it happens but you can review the encryption or something like that, because if you haven't any prblms with Fonction Parametres, that's mean your Uuid is good but you don't need to encrypt because the Nordre is the also the same for all of first requests. You need to encrypt with the bytes generated that help to generate the uuid as the documentation says, we tried it but no result, keep searching...

bain3 commented 1 year ago

There was a mistake in the protocol description. Fixed in 0cd9696e. (you can see the implementation here)

Sorry for the confusion.

OmegaMax commented 1 year ago

Thanks !

XibalbaM commented 1 year ago

Yeah after hours of trying I finally got it working, I have support for basic pronote connection for the moment. The thing that gave me the most of my problems was strangely the handling of bytes/string/hex and the encryption function not working exactly the same way as in python and JavaScript For the moment my lib is tested only for kotlin but I hope I'll have support for JavaScript too soon https://github.com/XibalbaM/PronoteKt

OmegaMax commented 1 year ago

We are trying in javascript and we are stuck, since... too long...

XibalbaM commented 1 year ago

The code is public ? Maybe I can help. Else with kotlin multiplatform I'll be able to publish the same code for Java-Based, JavaScript and C-Like (using native libraries) That's why I made it with kotlin, because it's the best for compatibility across many languages

OmegaMax commented 1 year ago

Sorry for the late answer it was night, hum, the code is not public enought but we will share you if we have no idea because we want to test something, we will tell you later ! Thanks to purpose your help

OmegaMax commented 1 year ago

We have finally success !

OmegaMax commented 1 year ago

@bain3 I think you can add that the G: 14 error is from the fact that we use the http model (in the doc, so with the rsa) instead of https model when we need https It's just a hypothesis

XibalbaM commented 1 year ago

I wrote that (it's just what I saw, not necessarily exact) https://github.com/XibalbaM/PronoteKt/blob/master/src/main/kotlin/INFOS.md

OmegaMax commented 1 year ago

Hum, I don't know why, my code is just illogical and it works : I send by mistake the third request to do, so the identification request instead of Uuid request, so I send it two times and I don't know why it works, I have a succeful answer with the challenge. And all of it was made without the request with Uuid. Do you know why ?

OmegaMax commented 1 year ago

And then I try to do exactly the same thing for auth because I was curious that why its working. And I send also the request (without challenge, just the identification) and it replies something without solved challenge but juste "Acces : 1" but there's no errors, it's very strange...

XibalbaM commented 1 year ago

I think the API isn't meant to be used by strangers so it explains why the errors are so random

OmegaMax commented 1 year ago

it's strange because if I use the classical way it doesn't works

OmegaMax commented 1 year ago

Idk if you have this error but I found it : G 23 : 'Vous avez dépassé le nombre d'erreurs d'authentification autorisées.\nVeuillez patienter avant de réessayer.'

OmegaMax commented 1 year ago

and also : Erreur: {G: 9, Titre: 'La page a expiré ! (2)', Message: ''} when you skip a step i think