I have a GAE app running on the Java Development Server (AKA devserver) on my local machine that defines some Task Queue pull queues.
I want to use the Task Queue REST API from a different standalone Java app, running on my machine, to access these pull queues.
I tried the sample suggested by Google's documentation that implements leasing tasks. Apparently, it uses the Google API Client Library for Java that requires a client_secrets.json
file of the format:
{
"installed": {
"client_id": "retrieved from creating a Service Account for the project",
"client_secret": "supposedly appears in the JSON file that's downloaded upon creation of a Service Account for the project"
}
}
I created a Service Account for the project and a JSON was automatically downloaded, with the following format:
{
"type": "service_account",
"project_id": "myProjectId",
"private_key_id": "some long hexadecimal",
"private_key": "an even longer encrypted stuff",
"client_email": "myServiceAccountName@myProjectId.iam.gserviceaccount.com",
"client_id": "a decimal number",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://accounts.google.com/o/oauth2/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/myServiceAccountName%40myProjectId.iam.gserviceaccount.com"
}
In my client_secrets.json
file I used private_key_id
as the client_secret
value and executed the sample code.
The result was that it opened https://accounts.google.com/o/oauth2/auth
in my browser, which displayed an error with status code 400
and the following message:
Error: redirect_uri_mismatch Application: My Application The redirect URI in the request: http://localhost:61130/Callback did not match a registered redirect URI.
I tried Taskqueue.Builder.setRootUrl("http://localhost:8080")
, although its javadoc says not to mess with it. It returned 401 Unauthorized
.
- Is there a way to use the Task Queue REST API from a standalone Java app to access these pull queues? I prefer using the Java libraries offered by Google but apparently they automatically point to the actual GAE services.
- What should I use as the value of
client_secret
1 in theclient_secrets.json
file when I do want to lease tasks from Google App Engine on the cloud?
1 When I created the Service Account, since I'm not the owner of the project, I got the following message:
The service account could not be added to this project's permissions because you are not an owner of the project. To give the service account access to this project, ask a project owner to add it to the project permissions.
I wonder whether this has something to do with the absence of a client_secret
property in the automatically downloaded JSON.