

Google API storage returns string, not object of credentials
source link: https://www.codesd.com/item/google-api-storage-returns-string-not-object-of-credentials.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Google API storage returns string, not object of credentials
I'm trying to use the google-api for python. I've managed to store the credentials in a CredentialsField
(basically copying this) implementation.
I can get a storage object:
>>> storage = Storage(CredentialsModel, 'id', user, 'credential')
>>> storage
<oauth2client.django_orm.Storage object at 0x7f1f8f1260f0>
no problem. But when I try to get the credentials object:
>>> credential = storage.get()
>>> credential
I just get a massive string (7482 characters) instead of a credentials object. What gives? (I think the string might be a bytearray, since it begins with '\\x67414e6a6
.
I'm also using Python 3.
Any thoughts on why I'm getting a string instead of a Credentials object?
I've actually found the answer if you still need it:
The problem is that the class CredentialFields in django_orm defined a metaclass variable, which isn't supported in python3 anymore.
Therefore, it is necessary to change it to something like this:
class CredentialsField(models.Field, metaclass=models.SubfieldBase):
someone has opened an issue in the github repo:
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK