Using Pull Task Queue REST API outside App Engine?

93 views
Skip to first unread message

Cristian Mastrantono

unread,
May 13, 2016, 9:37:05 AM5/13/16
to Google 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();



Christian F. Howes

unread,
May 16, 2016, 2:40:47 PM5/16/16
to Google App Engine
Hi,

you ask: "now I'm wondering if the queue must be created first before start using it" I am pretty sure that even on GAE you must update queue.yaml and deploy the new queue before GAE can use it, so I'd assume that is the same for the REST API.  I don't think that you can create queues on the fly, but you can use parameters on the tasks, or different URLs on the tasks to handle them differently.

good luck,

cfh
Message has been deleted

Cristian Mastrantono

unread,
May 16, 2016, 3:00:49 PM5/16/16
to Google App Engine
After more research... my conclusion is that the queue must be created with a GAE app... and then you can use it from CE through REST API. Because even if I define the queue in my queue.yaml (CE) it is not created. Never. 

Maybe someone can confirm this.

Thanks!

Evan Jones

unread,
May 16, 2016, 3:12:46 PM5/16/16
to Google App Engine
My understanding: Yes, you must have an App Engine application, and you must run appcfg.py update_queues to create the App Engine Task Queues before you can use them.

If you do not have an App Engine application, you should probably be using Google Pub/Sub instead. It is many times faster and more scalable, as well as supporting more sophisticated use cases. I work on an application that makes heavy use of App Engine Task Queues, and while they are pretty good, they have some interesting limitations that Pub/Sub solves.

Hope that helps,

Evan

Christian F. Howes

unread,
May 16, 2016, 4:23:47 PM5/16/16
to google-a...@googlegroups.com
have you used appcfg.py update_queues?

https://cloud.google.com/appengine/docs/python/tools/appcfg-arguments#update_queues

On 5/16/16 11:59, Cristian Mastrantono wrote:
> After more research... my conclusion is that the queue must be created with
> a GAE app... and then you can use it from CE. Because even if I define the
> queue in my queue.yaml (CE) it is not created. Never.
>
> Maybe someone can confirm this.
>
>
>
> On Monday, May 16, 2016 at 3:40:47 PM UTC-3, Christian F. Howes wrote:
>>
>> Hi,
>>
>> you ask: "*now I'm wondering if the queue must be created first before
>> start using it"* I am pretty sure that even on GAE you must update
>> queue.yaml and deploy the new queue before GAE can use it, so I'd assume
>> that is the same for the REST API. I don't think that you can create
>> queues on the fly, but you can use parameters on the tasks, or different
>> URLs on the tasks to handle them differently.
>>
>> good luck,
>>
>> cfh
>>
>> On Friday, May 13, 2016 at 6:37:05 AM UTC-7, Cristian Mastrantono wrote:
>>>
>>> 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* ...

Cristian Mastrantono

unread,
May 16, 2016, 4:32:31 PM5/16/16
to Google App Engine
Christian: Thanks! I will take a look... my goal was to set up and use the queues without having to have a GAE app deployed, but maybe I should consider doing a dumb GAE app just to set tup the queues.

Evan: awesome! Didn't know about Pub Sub existence... I need just simple queues, but maybe Pub Sub is the best solution if your app does not run in GAE yet.

Thanks everyone!
Reply all
Reply to author
Forward
0 new messages