Skip to content

Build using google credentials #87

Open

Description

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)

Activity

  1. tylertreat commented on Apr 18, 2016

    @tylertreat
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions