Jayapraveen / INE-courses-downloader

Python Script to download coures from INE.com website for personal and educational use
GNU General Public License v3.0
39 stars 19 forks source link

Access token entered is faulty #43

Closed Extremalzhez closed 2 years ago

Extremalzhez commented 2 years ago

HI, again, after I've changed line refresh_token = login_data["data"]["tokens"]["data"]["Bearer"] I've got access, but after choosing 2 it just freeze, i have closed the window and reopened again and now i'm hitting this error:

access token entered is faulty. Check for and correct errors!

Should i wait for 4hrs to refresh the token or?

ghost commented 2 years ago

no delete the token.txt file in the folder

Extremalzhez commented 2 years ago

fixed by deleting "ine_tokens.txt" Thank you!

ghost commented 2 years ago

here's the easy fix so not having ot delete it every time start script. add os.remove in main like so

`

if name == 'main': if not (sys.version_info.major == 3 and sys.version_info.minor >= 6): print("This script requires Python 3.6 or higher!") exit("You are using Python {}.{}".format(sys.version_info.major, sys.version_info.minor)) os.system('cls') if os.name == 'nt' else os.system('clear') print("INE Courses Downloader\n")

if os. path. exists(token_path):
    os. remove(token_path)

if(os.path.isfile(token_path)):
    with open(token_path,'r') as fp:
        try:
            fp = json.loads(fp.read())
            access_token = fp["access_token"]
            refresh_token = fp["refresh_token"]
            access_token = "Bearer "+ access_token
        except:
            print("Please check the data in token file and correct for errors")
    if(len(access_token) == 0):
        print("Please refer to readme.md in github and set the access_token")
        exit()
    if(len(access_token) != 1009):
        print("Access token entered is faulty. Check for and correct errors!")
        exit()
    if(len(refresh_token) == 0):
        print("Please refer to readme.md in github and set the refresh_token")
        exit()
    if(len(refresh_token) != 1784):
        print("Refresh token entered is faulty. Check and correct errors!")
        exit()
    auth_check()
else:
    login()

`

ghost commented 2 years ago

this will remove the file and recreate it each run

Extremalzhez commented 2 years ago

do i need create a new scrpit and put this on new file? or should i add it to current ine.py file?

ghost commented 2 years ago

best to make a copy and add it to the copy

Extremalzhez commented 2 years ago

can you explain little bit where should i put this lines? at existitng script or should create a new one?

Extremalzhez commented 2 years ago

send dm please