"Access Denied" when trying to access BigQuery on GCE
<p>I developed and built a jar file is processing read from two BigQuery tables and then write it another BigQuery table.
(There are three GCP projects and each project has own BigQuery table.)
The jar file is a result building and packaging by Maven. I used Dataflow SDK dependency. </p>

<p>After building a jar file, I tested it on my Mac and I checked it works well.
And then, I uploaded a jar file to GCE and tested it again. I thought it would work well but it occurs some error like this :</p>

<p>com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
{
  "code" : 403,
  "errors" : [ {
    "domain" : "global",
    "message" : "Access Denied: Dataset ${PROJECT_ID}:${DATASET_ID}: The user ${MY_ACCOUNT_ID} does not have bigquery.tables.list permission for dataset ${PROJECT_ID}:${DATASET_ID}.",
    "reason" : "accessDenied
....
}</p>

<p>When I created GCE instance, I set service account properly. I am sure it`s not about this.</p>

<p>I do not understand why same jar runs differently, makes error or not?</p>

<p>The account on testing is member or owner of three projects.
Before testing, I use this commands on my Mac and GCE :</p>

<ol>
<li>gcloud auth login</li>
<li>gcloud config set project rgpkorea-datalake</li>
<li>gcloud auth application-default login</li>
</ol>

<p>In Java project, I created credential object and build BigQuery service with credential object.</p>

<pre><code>GoogleCredential credential = GoogleCredential.getApplicationDefault(HTTP_TRANSPORT, JSON_FACTORY);
Bigquery bigquery = new Bigquery.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential)
                .setApplicationName("BdtAndroidGaSessionMigrator" + CalendarUtil.getYesterdayAsDateFormat()).build();
List&lt;Tables&gt; tableList = bigquery.tables().list("${PROJECT_ID}", "${DATASET_ID}").setMaxResults(9999999L).execute().getTables();
</code></pre>

<p>For security, I replaced project id and dataset id as EL expression.</p>

<p>As you know as, "gcloud init" command is supported on Google-Cloud-SDK. I also tried "gcloud init" command, but result is not different.
In my guess, above commands work differently depends on environments such as GCP instance or local machine.</p>

<p>How do I resolve "Access denied" issue? please help this.</p>

<p>P.S.
Forgive my poor English.
I doubt my English presents what I have problem to you exactly.</p>