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

Build using google credentials #87

Open
ghost opened this issue Apr 8, 2016 · 1 comment
Open

Build using google credentials #87

ghost opened this issue Apr 8, 2016 · 1 comment

Comments

@ghost
Copy link

ghost commented Apr 8, 2016

It's possible to build a service using GoogleCredentials? I tried giving the GoogleCredentials as parameter, but it crashes when building the service:
service = build('bigquery', 'v2', http=http, discoveryServiceUrl=service_url)
I'm doing something like this:
get_client(project, credentials=GoogleCredentials.get_application_default(), private_key="private_key.json", readonly=False)
But I got:

oauth2client.client.AccessTokenRefreshError: invalid_scope: Empty or missing scope not allowed.

I just don't know if I'm doing something wrong or if I don't know how to use the lib/services correctly.. but I believe I need something like this
discovery.build('bigquery', 'v2', credentials=credentials)

@tylertreat
Copy link
Owner

This should work. Perhaps you need to do something like this?

from bigquery.client import BIGQUERY_SCOPE
credentials = GoogleCredentials.get_application_default()
scopes = BIGQUERY_SCOPE
credentials = credentials.create_scoped(scopes)

Looking closer at your example, if you're providing a private key file, you should use the private_key_file kwarg, not private_key which takes the key as a string. Also, if you're providing credentials, you shouldn't have to provide a private key.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant