This repository was archived by the owner on Feb 24, 2026. It is now read-only.
Add get_user_credentials function to get your user credentials.#40
Merged
busunkim96 merged 9 commits intogoogleapis:masterfrom Jun 10, 2019
Merged
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)
```
busunkim96
reviewed
Apr 26, 2019
Contributor
Author
Contributor
|
LGTM, but I think it would be best to have a few more people set eyes on it. |
busunkim96
approved these changes
Jun 4, 2019
Contributor
|
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>
.
|
Contributor
Author
|
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>
.
|
Contributor
Author
|
@busunkim96 This PR is ready for another review. Once this is merged, is autorelease configured for this repo? |
Contributor
|
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 |
Contributor
Author
Great idea. Done! I've confirmed that it renders well in the docs. |
busunkim96
approved these changes
Jun 10, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


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 logincommand-line tool, so should work for most Google APIs.
Tested manually with the BigQuery API:
Closes #39