Below is a working code sample that we are using to get a larger customer. We want to tweak it so that we can query in different projects. For example, the queries that run on Project 1, but save the result in the table in Project 2. What I had to do, was to get certification for Project 2, but the questions asked in Project 1 were to present the complete path reference of the tables, but when writing this, the job was not failed AccessDenied: Access denied . (Job_id: job_queryToTable_c43f8d51-01a5-492c-b648-e15171bb65db_266866506361660). What should I do?
Private zero getBigQuery () {if (mBigquery == faucet) {HttpTransport transport = New NetHttpTransport (); & Lt; String & gt; LScope = New Arrestist & lt; String & gt; (); LScope.add (ConfigConstants.SCOPE); GoogleCredential Credentials; {Credential = new GoogleCredential.Builder () .setTransport (Transportation) .setJsonFactory (ConfigConstants.JSON_FACTORY) .setServiceAccountId (ConfigConstants.SERVICE_CLIENT_ID) .setServiceAccountScops (lScope) .setServiceAccountPrivateKeyFromP12File (New File (ConfigConstants.KEY_FILE)). MBigquery = New Bigquery.Builder (Transport, ConfigConstants.JSON_FACTORY, Credential) .setApplicationName ("BigQuery-Service-Account / 0.1") .setHttpRequestInitializer (Credential) .build (); } Grip (General Security Exhibit e) {// TODO e.printStackTrace (); } Hold (IOException e) {// TODO e.printStackTrace (); }}}
Invalid grant came when I tried to get information about table in another project
table Table = mBigquery.tables (). Get (project2, dataset, tableId) .execute (); // mBigquery is with the credentials for Project 1 and the table for Project 2 is found
< P> Understand this: Go to Google Developer Console - Add Project 2 Service Account by Using Project 2 -> Add Member -> Account 2 Customer ID, Then It Works
< / Html>
Comments
Post a Comment