Cristian
Cristian

Reputation: 73

How to use Google Pull Task Queue REST API outside App Engine?

I'm having trouble dealing with the Pull Task Queue REST API. Whenever I try it says "403 - you are not allowed to make this api call". I'm trying this in my computer, which is obviously out of the App and Compute Engine.

I have my Service account credential, my queue.xml in WEB-INF, and now I'm wondering if the queue must be created first before start using it ... is that necessary?

This is my code... Am I missing something?

JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance();
HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();

List<String> scopes = new ArrayList<>();
scopes.add(TaskqueueScopes.TASKQUEUE);
scopes.add(TaskqueueScopes.TASKQUEUE_CONSUMER);

ClassLoader classloader = Thread.currentThread().getContextClassLoader();
InputStream is = classloader.getResourceAsStream("credential-12356.json");

GoogleCredential credential = GoogleCredential.fromStream(is).createScoped(scopes);

Taskqueue taskQueue = new Taskqueue.Builder(httpTransport, JSON_FACTORY, credential).setApplicationName(APPLICATION_NAME).build();

Taskqueue.Taskqueues.Get request = taskQueue.taskqueues().get(projectId, taskQueueName);
request.setGetStats(true);

//Get the queue!
TaskQueue queue = request.execute();

Upvotes: 0

Views: 214

Answers (1)

Cloud Newbie
Cloud Newbie

Reputation: 61

Did you configure email address in your queue configuration in queue.xml?

<queue>
    <name>pull-queuqueue</name>
    <mode>pull</mode>
    <rate>10/s</rate>
     <acl> 
      <user-email>[email protected]</user-email>
    </acl>
 </queue>

Upvotes: 0

Related Questions