-
Notifications
You must be signed in to change notification settings - Fork 83
Add get_user_credentials
function to get your user credentials.
#40
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
Add get_user_credentials
function to get your user credentials.
#40
Conversation
This function is intended to be used in interactive code examples, such as from a Jupyter notebook or when developing scripts locally. It uses the same client ID as the `gcloud auth authentication-default login` command-line tool, so should work for most Google APIs. Tested manually with the BigQuery API: ``` import os import google_auth_oauthlib from google.cloud import bigquery credentials = google_auth_oauthlib.get_user_credentials( ["https://www.googleapis.com/auth/cloud-platform"] ) client = bigquery.Client( credentials=credentials, project=os.environ["PROJECT_ID"], ) df = client.query( """ SELECT CONCAT( 'https://stackoverflow.com/questions/', CAST(id as STRING)) as url, view_count FROM `bigquery-public-data.stackoverflow.posts_questions` WHERE tags like '%google-bigquery%' ORDER BY view_count DESC LIMIT 10 """ ).to_dataframe() print(df) ```
LGTM, but I think it would be best to have a few more people set eyes on it. |
I see more interest in this in googleapis/google-auth-library-python#271, have you heard from anyone on this? |
I *really* don't think we should perpetuate the use of that shared client
ID. I would chat with Hong before going forward here.
…On Tue, Jun 4, 2019 at 9:34 AM Bu Sun Kim ***@***.***> wrote:
I see more interest in this in googleapis/google-auth-library-python#271
<googleapis/google-auth-library-python#271>,
have you heard from anyone on this?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#40?email_source=notifications&email_token=AAB5I44Q2OTUWWPZTYUFBDTPY2KRZA5CNFSM4HI24HF2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODW5ETCA#issuecomment-498747784>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAB5I4Y2P3OIPFJ5HOZKZ6DPY2KRZANCNFSM4HI24HFQ>
.
|
What if we make client ID and client secret required? |
That's fine.
…On Tue, Jun 4, 2019 at 9:52 AM Tim Swast ***@***.***> wrote:
What if we make client ID and client secret required?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#40?email_source=notifications&email_token=AAB5I43DU7HW6TWR5IQAW4LPY2MU5A5CNFSM4HI24HF2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODW5GHGY#issuecomment-498754459>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAB5I4253QCXHRFPT2YMVK3PY2MU5ANCNFSM4HI24HFQ>
.
|
@busunkim96 This PR is ready for another review. Once this is merged, is autorelease configured for this repo? |
It'll be a manual release. (looks like this repo still needs to be moved off of Travis, in fact 😦) Would you mind adding an example of how to use this in the comments like we have for |
Great idea. Done! I've confirmed that it renders well in the docs. |
This function is intended to be used in interactive code examples, such
as from a Jupyter notebook or when developing scripts locally. It uses
the same client ID as the
gcloud auth authentication-default login
command-line tool, so should work for most Google APIs.
Tested manually with the BigQuery API:
Closes #39