Reputation: 1458
I saw some similar questions but none of them actually gives a concrete solution to this problem.
The message I'm getting is this one:
HttpError 401 when requesting https://www.googleapis.com/bigquery/v2/projects/project/queries?alt=json returned "Invalid Credentials"
Code that connects to BigQuery:
appname = get_application_id()
project_id = appname
# Grab the application's default credentials from the environment.
credentials = GoogleCredentials.get_application_default()
# Construct the service object for interacting with the BigQuery API.
bigquery_service = build('bigquery', 'v2', credentials=credentials)
query_request = bigquery_service.jobs()
query_data = {
'query': query,
'useLegacySql': use_legacy_sql
}
query_response = query_request.query(
projectId=project_id,
body=query_data).execute()
What could be the cause(s) for this problem?
Upvotes: 0
Views: 1274
Reputation: 14781
Make sure:
GOOGLE_APPLICATION_CREDENTIALS
to point to the file created in step 1.Then it will work. More details can be found here.
Upvotes: 1