Skip to content
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

AutoML: pass credentials from Table client to underlying client. #9490

Closed
shunghsiyu opened this issue Oct 17, 2019 · 0 comments · Fixed by #9491
Closed

AutoML: pass credentials from Table client to underlying client. #9490

shunghsiyu opened this issue Oct 17, 2019 · 0 comments · Fixed by #9491
Assignees
Labels
api: automl Issues related to the AutoML API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@shunghsiyu
Copy link
Contributor

Problem

It seems that TablesClient doesn't correctly pass the credentials down to underlying clients.

Since I have neither a default credential nor GOOGLE_APPLICATION_CREDENTIALS set on my machine, I end up getting DefaultCredentialsError.

Environment details

os: macOS 10.14.2
python version: 3.7
google-cloud-automl==0.7.0

Code example

from google.cloud import automl_v1beta1
from google.oauth2 import service_account


credentials = service_account.Credentials.from_service_account_file('sa.json')
client = automl_v1beta1.TablesClient(
    credentials=credentials,
    project=credentials.project_id,
    region='us-central1',
)

Stacktrace

/Users/account/project/.venv/bin/python /Users/account/project/prediction_starter/main.py
Traceback (most recent call last):
  File "/Users/account/project/prediction_starter/main.py", line 9, in <module>
    region='us-central1',
  File "/Users/account/project/.venv/lib/python3.7/site-packages/google/cloud/automl_v1beta1/tables/tables_client.py", line 110, in __init__
    client_info=client_info_, **kwargs
  File "/Users/account/project/.venv/lib/python3.7/site-packages/google/cloud/automl_v1beta1/gapic/auto_ml_client.py", line 265, in __init__
    address=api_endpoint, channel=channel, credentials=credentials
  File "/Users/account/project/.venv/lib/python3.7/site-packages/google/cloud/automl_v1beta1/gapic/transports/auto_ml_grpc_transport.py", line 67, in __init__
    "grpc.max_receive_message_length": -1,
  File "/Users/account/project/.venv/lib/python3.7/site-packages/google/cloud/automl_v1beta1/gapic/transports/auto_ml_grpc_transport.py", line 104, in create_channel
    address, credentials=credentials, scopes=cls._OAUTH_SCOPES, **kwargs
  File "/Users/account/project/.venv/lib/python3.7/site-packages/google/api_core/grpc_helpers.py", line 177, in create_channel
    credentials, _ = google.auth.default(scopes=scopes)
  File "/Users/account/project/.venv/lib/python3.7/site-packages/google/auth/_default.py", line 317, in default
    raise exceptions.DefaultCredentialsError(_HELP_MESSAGE)
google.auth.exceptions.DefaultCredentialsError: Could not automatically determine credentials. Please set GOOGLE_APPLICATION_CREDENTIALS or explicitly create credentials and re-run the application. For more information, please see https://cloud.google.com/docs/authentication/getting-started

Expected Behavior

Successfully instantiate a TablesClient instance.

shunghsiyu added a commit to shunghsiyu/google-cloud-python that referenced this issue Oct 17, 2019
In automl_v1beta1.TablesClient.__init__(), the credentials
are not given to AutoMlClient and PredictionServiceClient,
causing inconsistency between the credentials that was passed
and the credentials that was actually used for API calls.

This commit ensures that credentials are passed, and add two
unittests to catch the behavior.

Fixes googleapis#9490
@busunkim96 busunkim96 added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. api: automl Issues related to the AutoML API. labels Oct 17, 2019
@tseaver tseaver added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. and removed priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Oct 22, 2019
@tseaver tseaver changed the title AutoML: Table client does not make use of credentials passed AutoML: pass credentials from Table client to underlying client. Oct 22, 2019
busunkim96 pushed a commit that referenced this issue Oct 28, 2019
…9491)

In automl_v1beta1.TablesClient.__init__(), the credentials
are not given to AutoMlClient and PredictionServiceClient,
causing inconsistency between the credentials that was passed
and the credentials that was actually used for API calls.

This commit ensures that credentials are passed, and add two
unittests to catch the behavior.

Fixes #9490
parthea pushed a commit that referenced this issue Oct 21, 2023
…9491)

In automl_v1beta1.TablesClient.__init__(), the credentials
are not given to AutoMlClient and PredictionServiceClient,
causing inconsistency between the credentials that was passed
and the credentials that was actually used for API calls.

This commit ensures that credentials are passed, and add two
unittests to catch the behavior.

Fixes #9490
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: automl Issues related to the AutoML API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants