I want to run a cron job on GAE that internally calls BigQuery.

I am currently able to run BigQuery but I need to log in with my credentials. But I would like to run the cron job for BigQuery without any login.

Any help would be highly appreciated.

有帮助吗?

解决方案 2

I am successfully able to implement it in java.Before performing it we need to generate client id for service account.

private static final HttpTransport TRANSPORT = new NetHttpTransport();
private static final JsonFactory JSON_FACTORY = new JacksonFactory();
private static Bigquery bigquery;




AppIdentityCredential credential = new AppIdentityCredential(Collections.singleton(BigqueryScopes.BIGQUERY));
bigquery = new Bigquery.Builder(TRANSPORT, JSON_FACTORY, credential)
            .setApplicationName("BigQuery-Service-Accounts/0.1")
            .setHttpRequestInitializer(credential).build();

其他提示

I know it's not the java you're expecting. The secret is to use AppAssertionCredentials. Here is the python sample:

from apiclient.discovery import build
from oauth2client.appengine import AppAssertionCredentials
import httplib2
from google.appengine.api import memcache

scope = 'https://www.googleapis.com/auth/bigquery'

credentials = AppAssertionCredentials(scope=scope)

http = credentials.authorize(httplib2.Http(memcache))

return build("bigquery", "v2", http=http)
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top