My App engine is running in project-1. I want to access the BQ present in project-2. How can i make app engine in project-1 access the BQ present in project-2?
2 Answers
You should request "can view" (or "can edit") permissions on the dataset of your interest. Owner of project-2 (or respective dataset) will be able to do so.
You don't need to be present on project level and in some cases it is not even appropriate - but you must have appropriate permissions on dataset level
If, by chance, you are the owner of project-2 or respective dataset - you can easily do this by following below instructions
https://cloud.google.com/bigquery/bigquery-web-ui#sharedataset

- 165,386
- 8
- 154
- 230
The easiest way to accomplish this is to add the default service account of "project-1" to the permissions list of "project-2":
- within the cloud console go to the permissions section of project-1
- select the service accounts sub tab
- look for the default service account (or create a new one)
- add the service account to the permissions of project-2
EDIT
You need to create your client in a fashion that uses the applications default service account. For example if you're using python it would look something like:
# 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)
Now with your PK file you can launch the dev appserver in a fashion that the same client client will work correctly: Unable to access BigQuery from local App Engine development server
-
Thanks Jesse. I was given with service acct and Pk12 file for project-2. I have used these in project-1 App engine. Do i need to create client id in project-2 so that i can use it in App engine? If i follow these steps, i am able to run the App engine code correctly in my local machine but not in the cloud. When i run the App engine code in the cloud i see invalid token or 401 authorized error. – bigdata Mar 25 '16 at 05:44
-
You would use the pk12 file for local development. The convention for running in the cloud is by following my steps or those of @Mikhail – Jesse Mar 26 '16 at 16:52
-
Thanks Jesse. I want to design my App so that it can be run locally and on the cloud. How would i do that without PK12 file? – bigdata Mar 27 '16 at 06:08
-
I have one more basic question. How can i create BQ service without PK12 file. When i create the BQ client (https://cloud.google.com/bigquery/bigquery-api-quickstart) will the BQ service be created using the default service account? – bigdata Mar 27 '16 at 06:12
-
When i try to get the BQ service using the default service account, i am getting the bigquery_service instantiated to null. Then i did bigquery_service.getServiceAccountId() and i got null for my service account. – bigdata Mar 28 '16 at 17:35