Giter Club home page Giter Club logo

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

View Code? Open in Web Editor NEW
24.0 1.0 11.0 105 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 100.00%
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

iitkgp-erp-login-pypi's Introduction

Hi there , I'm Arpit Bhardwaj aka proffapt

I am an undergraduate from IIT Kharagpur.

Interested (and hence Reads) about Computers, Quantum Mechanics and Astronomy.
I sometimes write on blog.proffapt.me.

⭕️ For Professional details - READ MY RESUME


iitkgp-erp-login-pypi's People

Contributors

proffapt avatar rohan-b-84 avatar shikharish avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

iitkgp-erp-login-pypi's Issues

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
  • ERP credentials storage
  • Fetching OTP automatically? By providing GMAIL API token.json and storing it?

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.

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.

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'})

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.

[NEXT UPDATE] Correct wrong info on readme

> **Note** This is merely a Proof of Concept example; this exact functionality has been integrated into the login function itself from version **2.1.0** onwards.
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] 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

[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".

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.
Something like: _, ssoTOken = erp.login(headers, session, WEBAPP=True)

Version

If done it will be v2.4.0.

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.