loumadev / EdupageAPI

Simple node.js package to manage your EduPage account.
GNU General Public License v3.0
26 stars 2 forks source link

Can't login #17

Closed checkm4te8 closed 2 years ago

checkm4te8 commented 2 years ago

Hi @loumadev , I'm trying to use your API but I get an error: edupage.login(process.env.USERNAME, decryptedpass).then(user => { that the password is incorrect. It is, however correct, the issue is that I cannot login via portal.edupage.org, I need to login via subdomain.edupage.org, however this API unlike the python edupage api does not support the subdomain option for logging in. How can I proceed otherwise? Thanks.

loumadev commented 2 years ago

Hello. Actually, you can provide a subdomain. By a new version, there's an ability to pass LoginOptions object as a 3rd argument to Edupage.login method. The definition of the LoginOptions is:

/**
 * @typedef {Object} LoginOptions
 * @prop {string | null | undefined} [code2FA=undefined] If the provided value is typeof `string`, it's considered as a 2FA code (should be provided after first unsuccessful login). If it's `null` the 2FA will be skipped. If omitted or `undefined` and the 2FA is requested by the Edupage, the function will resolve with `null`.
 * @prop {string} [user] Can be used to select a specific user in case there are more.
 * @prop {string} [edupage=""] The edupage subdomain (origin) to login to. Try to set this if you have trouble logging in (e.g. incorrect password error).
 */

By the definition, you can see that this is one of the possible behaviours and the solution to this is to provide a subdomain (or, as it's called in this package, an origin). The Edupage don't differ "wrong password" from "missing edupage", so there's nothing I can do about it, just to inform the user to provide the edupage (subdomain) as well.

You should see an error like this: Failed to login: Incorrect username. (If you are sure that the username is correct, try providing 'edupage' option) In case you didn't get this error, you might need to update the package to the latest version (because this is a relatively new feature).

Let me know if it helped.

checkm4te8 commented 2 years ago

@loumadev Hi, thank you so much for the response and good News, I tried using it but to be frank, I couldn't figure out how to use the LoginOptions, could you please provide an example by any chance? It'd help a lot.

Thanks!

loumadev commented 2 years ago

The syntax is like this:

await edupage.login(USERNAME, PASSWORD, {edupage: "subdomain"});
checkm4te8 commented 2 years ago

@loumadev That worked, thank you so much!