-
Notifications
You must be signed in to change notification settings - Fork 314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Credentials to_json method could have clearer documentation and API #494
Comments
The
Is it a good idea to just replace |
Thanks for the quick note, @alvyjudy.
I think that would help. Maybe also point to |
Hi @adelevie, tbh I'm not an expert either. But token is not necessary in the construction of
(I didn't test this but it is my understanding. Hope it isn't wrong) This is a snippet that shows how
Side note on the |
from #494, this PR updated the docstring of ``to_json`` method in the credential so that it points user to ``from_authorized_user_info`` instead of the non-existent ``from_json``
An additional note on to_json - it doesn't serialize the "type" which the from_authorized_user_info relies on to read user auth (as opposed to service account auth) based credentials. |
Is your feature request related to a problem? Please describe.
I need to serialize the
Credentials
data as JSON, and I just discovered theto_json
method. It's very helpful, as the pickle-related techniques in the quickstart (e.g. https://developers.google.com/docs/api/quickstart/python) rely on the file system and binary data, which means the token cannot be persisted in an environment variable (useful for Heroku and other server deployments).Anyways, the
to_json
method has the following in the doc string:I looked and looked for
from_json()
and couldn't find it in this library. If it does exist, I can't find it, and maybe should be easier to find. Assuming it doesn't exist, I found (mostly) what I needed in the class methodfrom_authorized_user_info
:That last line is used to ensure
creds.valid
returnsTrue
.Describe the solution you'd like
The documentation and/or API for serializing/de-serializing as JSON should be clearer. If there is a
from_json
method, it should be mentioned somewhere in the docs. If there isn't, the doc string into_json
should specify the (class) method most suitable to ingest the serialized JSON. If that method happens to befrom_authorized_user_info
, it should ingest thetoken
key as well, avoiding the need for the sort of hacky value set after instantiation/building.Describe alternatives you've considered
The alternative I considered is the code sample for my workaround mentioned earlier in this issue.
Additional context
None I can think of.
The text was updated successfully, but these errors were encountered: