Skip to content

Instantly share code, notes, and snippets.

@perryism
Created July 28, 2023 23:31
Show Gist options
  • Save perryism/23e1aee4193e085fe67bcef2f1004aa1 to your computer and use it in GitHub Desktop.
Save perryism/23e1aee4193e085fe67bcef2f1004aa1 to your computer and use it in GitHub Desktop.
Query bigquery on behave of an user
from google.oauth2.credentials import Credentials
from google.cloud import bigquery
import google.oauth2.credentials
import os
PROJECT = os.environ.get("PROJECT")
# gcloud auth print-access-token
ACCESS_TOKEN = os.environ.get("ACCESS_TOKEN")
credentials = google.oauth2.credentials.Credentials(ACCESS_TOKEN)
client = bigquery.Client(project=PROJECT, credentials=credentials)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment