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.
feat: updates the user instructions re OAuth #603
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
feat: updates the user instructions re OAuth #603
Changes from all commits
6325097
608668d
70bd131
baaad7b
dd66ebe
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
Authentication (Highly Constrained Development Environments)
Before you begin, you must create a Google Cloud Platform project. Use the BigQuery sandbox to try the service for free.
pandas-gbq authenticates with the Google BigQuery service via OAuth 2.0. Use the
credentials
argument to explicitly pass in Google :class:`~google.auth.credentials.Credentials`.Authenticating from Highly Constrained Development Environments
These instructions are primarily for users who are working in a highly constrained development environment.
Highly constrained development environments typically prevent users from using the Default Authentication Methods and are generally characterized by one or more of the following circumstances:
gcloud
).If the conditions above do not apply to you, your needs may be better served by the content in the Default Authentication Methods section.
When dealing with highly constrained environments, there are two primary options that one can choose from: Testing Mode OR an institution-specific authentication page.
OPTION 1 - Testing Mode
This approach is for limited use, such as when testing your product. It is not intended for production use. If you have fewer than 100 users, it is possible to configure User Type as External and the Publishing Status of your Project as Testing Mode to enable OAuth Out-of-Band (OOB) Authentication. NOTE: general purpose OOB Authentication was deprecated for all use cases except Testing Mode.
Note
Projects configured with a Publishing Status of Testing are limited to up to 100 test users who must be individually listed in the OAuth consent screen. A test user consumes a Project's test user quota once added to the Project.
Authentications by a test user will expire seven days from the time of consent. If your OAuth client requests an offline access type and receives a refresh token, that token will also expire.
To move a project from Testing Mode to In Production requires app verification and requires your institution to switch to using an alternate authentication method, such as an institution-specific authentication page.
The test users must be manually and individually added to your Cloud Project (i.e. you can not provide a group email alias for your development team because the system does not support alias expansion).
Google displays a warning message before allowing a specified test user to authenticate scopes requested by your Project's OAuth clients. The warning message confirms the user has test access to your Project and reminds them that they should consider the risks associated with granting access to their data to an unverified app.
For additional limitations and details about Testing Mode, see: Setting up your OAuth consent screen.
To enable Testing Mode and add users to your Cloud Project, in your Project dashboard:
To access BigQuery programmatically, you will need your Client ID and your Client Secret, which can be generated as follows:
Your Client ID and Client Secret are displayed in the pop-up. There is also a reminder that only test users that are listed on the Oauth consent screen can access the application. The client ID and Client Secret can also be found here, if they have already been generated:
With the Client ID and Client Secret, you are ready to create an OAuth workflow using code similar to the following:
To run this code sample, you will need to have
python-bigquery-pandas
installed. The following dependencies will be installed bypython-bigquery-pandas
:Sample code:
oauth-read-from-bq-testing-mode.py
OPTION 2 - Institution-specific authentication page
To access Bigquery programmatically, you will need your Client ID and your Client Secret, an OAuth authorization page, and an assigned redirect URI.
To add a Client ID, Client Secret, and Redirect URI to your Cloud Project, in your Project dashboard:
oauth.html
file shown below).Your Client ID and Client Secret will be displayed in the pop-up. The client ID and Client Secret can also be found here:
You will need to host a webpage (such as
oauth.html
) with some associated javascript (such as shown below inauthcodescripts.js
) to parse the results of the OAuth workflow.Code Sample:
oauth.html
Code Sample:
authcodescripts.js
With these items in place:
you are ready to create an OAuth workflow using code similar to the following:
To run this code sample, you will need to have
python-bigquery-pandas
installed. The following dependencies will be installed bypython-bigquery-pandas
:Sample Code:
oauth-read-from-bq-org-specific.py