metakgp / iitkgp-erp-login-pypi

The only python package you will ever need to implement login process in ERP for IIT-KGP
https://pypi.org/project/iitkgp-erp-login/
GNU Affero General Public License v3.0
26 stars 7 forks source link

[NEXT UPDATE] Correct wrong info on readme #18

Closed proffapt closed 1 year ago

proffapt commented 1 year ago

https://github.com/proffapt/iitkgp-erp-login-pypi/blob/5724f3d1e2d2a14955f799fa6793d74107f7b7d7/README.md?plain=1#L336 needs to be deleted :)

Also add sessionToken, ssoToken = to get the return values from erp.login. It is the only reason why this particular feature is not integrated into the login function itself. Just replace it with the text below:

import requests
import time

import erpcreds
# Importing erpcreds.py, which contains ERP credentials

import iitkgp_erp_login.erp as erp

headers = {
    'timeout': '20',
    'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/51.0.2704.79 Chrome/51.0.2704.79 Safari/537.36',
}
session = requests.Session()

print("Logging into ERP for:", creds.ROLL_NUMBER)

while True:
    if not erp.session_alive(session):
        _, ssoToken = erp.login(headers, session, ERPCREDS=erpcreds, LOGGING=True)
    else:
        print("Session is alive.")

    # Traverse ERP further using ssoToken

    time.sleep(2)
proffapt commented 1 year ago

Implemented in https://github.com/proffapt/iitkgp-erp-login-pypi/releases/tag/v2.3.1