简体   繁体   中英

How to store pickle file into sqlalchemy database python?

i have a python module userbot to managing folder/files https://github.com/adekmaulana/ProjectBish/blob/master/userbot/modules/google_drive.py from telegram and it runs on heroku.
However in function generate_credentials() after user finished authenticated user needs to put their token into heroku variable for next run, and it's kinda not user friendly because some user doesn't know how important \n in the token strings.
i wanted to make more user friendly by saving the credentials into pickle as google api drive v3 documentations says and store it into database, but i'm lost to begin with.
i've tried to put decoded credentials into strings and save it into sqlalchemy database but it give me strange bug when i load it, credentials thinks it runs on cloud console google??? it says:
raise exceptions.DefaultCredentialsError(__HELP_MESSAGE)
google.auth.exceptions.DefaultCredentialsError: could not automatically determine credentials. Please set GOOGLE_APPLICATION_CREDENTIALS or explicitly create credentials and re-run the application. For more information, please see https://cloud.google.com/docs/authentication/getting-started
any advice to make more user friendly would be much appreciate, thanks...

Updated:
So the problems is the credentials that i pull from database gets none after i called in build('drive', 'v3').

fixed by using credentials = Column(Text, nullable=False) before this fix i use credentials = Column(String) .
either String or Text are same i tried both, the only makes creds is empty after i pulled from database is because i don't use nullable=False before.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM