Giter Club home page Giter Club logo

proffapt / iitkgp-erp-login-pypi Goto Github PK

View Code? Open in Web Editor NEW
26.0 8.0 7.0 127 KB

The only python package you will ever need to implement login process in ERP for IIT-KGP

Home Page: https://pypi.org/project/iitkgp-erp-login/

License: GNU Affero General Public License v3.0

Python 92.57% Shell 7.43%
iit-kgp-erp iitkgp-erp python-package erp-login-py-package erp-python-package iit-kgp-erp-login iit-kgp-erp-login-python iitkgp-erp-login iitkgp-erp-login-python iitkgperp iitkgperplogin erp-login-python iitkgperploginpython proffapt-iitkgp proffapt-erp-login proffapt-iitkgp-erp-login python erp-autologin iitkgp-erp-autologin

iitkgp-erp-login-pypi's Issues

Better error logging

Error handling is top-notch (maybe).

But error logging is not. Provide user friendly error logs on already handled possible cases of errors.

Support for WebApps

v2.3.0

This is a proven robust solution for CLI application. The current goal is to make it support WebApps' workflow without any Breaking chnages for CLI applications.

Can there be a default login workflow for WebApps?

Idea

A default workflow of login in case of webapps integrated into the currently existing login() function.
Currently the workflow for webapps is broken into various steps through functions, basically like below:
image

What I want is a one liner to implement all of this from developer's perspective.
Break the workflow in 3-4 endpoints (as to-and-fro data passing is required). Implement those endpoints with proper error handling so that whichever frontend implements them can have proper logs.

Version

If done it will be v2.4.0.

Session & Credentials management for WebApps

Moving on from the basic iteration of just the workflow, integrating the specialities of CLI workflow into that of webapp will be wonderful.

  • sessionToken & ssoToken storage and retrieval

Rewrite in Rust

Is your feature request related to a problem? Please describe.
The package is written in Python. That is a big problem.

Describe the solution you'd like
Rewrite in Rust

Describe alternatives you've considered
Any language, really.

Continuous Integration

  • Implement Unit Tests
  • Implement Integration Tests
  • Trigger these tests on Pull Request using a pipeline

[NEXT UPDATE] Correct wrong info on readme

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)

[BUG]: session_valid() is broken

To Reproduce
Steps to reproduce the behavior:

  1. Use open_erp.py
  2. Logout ERP from browser
  3. Use open_erp.py again
  4. See error

Expected behavior
Either say it is valid or say it is not, and if it is something new then handle this case

Screenshots
image

Additional Context
Even if the session_valid() returns True in this case, the page says "The session is idle for too long time, re-login".

Auto-refresh tokens

This package utilises gmail api tokens, which get expired frequently and require manual intervention to refresh them which basically kills the whole point of automation. Fix it somehow, either using the documentation and implementing it correctly or use some other method.

gmail api not working for some reason

Getting the following error, whenever I generate a new token.json:

Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.11/site-packages/iitkgp_erp_login/erp.py", line 189, in login
    otp = getOTP(OTP_CHECK_INTERVAL)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/iitkgp_erp_login/read_mail.py", line 20, in getOTP
    creds = generate_token()
            ^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/iitkgp_erp_login/utils.py", line 73, in generate_token
    creds.refresh(Request())
  File "/opt/homebrew/lib/python3.11/site-packages/google/oauth2/credentials.py", line 335, in refresh
    ) = reauth.refresh_grant(
        ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/google/oauth2/reauth.py", line 351, in refresh_grant
    _client._handle_error_response(response_data, retryable_error)
  File "/opt/homebrew/lib/python3.11/site-packages/google/oauth2/_client.py", line 73, in _handle_error_response
    raise exceptions.RefreshError(
google.auth.exceptions.RefreshError: ('invalid_grant: Bad Request', {'error': 'invalid_grant', 'error_description': 'Bad Request'})

[Bug] OTP request not triggered for manual entry

Describe the bug
Choosing to enter OTP manually does not trigger OTP request. OTP is only requested with Google OAuth enabled. This prevents users who choose to enter OTP manually from receiving the code.

To Reproduce
Log in without the use of Google OAuth Credentials

Expected behavior
OTP should be requested regardless of chosen OTP retrieval method (manual or Google OAuth).

Screenshots
NA

Desktop (please complete the following information):
This bug is not specific to a particular desktop environment.

Smartphone (please complete the following information):
This bug is not specific to a particular mobile device.

Additional context
NA

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.