Receive a “RESPONSE” notification from Google Glass on the callbackURL endpoint

I am trying to change the example of the Google Glass Mirror quick-start mirror API to respond to the user response "RESPONSE".

I can display a valid map using the example with the REPLY built-in action.

I want the user to be able to respond with a reading of the scientific tool that I want to be able to display and return the map back to the user.

However, I am stuck at step zero. How to get the value that the user "answered".

Here is my attempt to sign up for a schedule. I can get the “SUBSCRIBE” message in my application log.

def _insert_a600_subscription(self): """Attempt to register to a600 updates""" subscription = { "collection" : 'timeline', "userToken" : self.userid, "callbackUrl":"https://myapp_on_appengine.appspot.com/logA600", } try: self.mirror_service.subscriptions().insert(body=subscription).execute() logging.info("SUBSCRIBED") except errors.HttpError, error: print 'An error occurred: %s' % e 

The map I generate is based on an example.

  def _insert_item_with_action(self): """Insert a timeline item user can reply to.""" logging.info('Inserting timeline item') body = { 'creator': { 'displayName': 'Python Starter Project', 'id': 'PYTHON_STARTER_PROJECT' }, 'text': 'A600 at current time:', 'id':'a600val', 'notification': {'level': 'DEFAULT'}, 'menuItems': [{'action': 'REPLY', }], } # self.mirror_service is initialized in util.auth_required. self.mirror_service.timeline().insert(body=body).execute() return 'A timeline item with action has been inserted.' 

I also created a "dummy" handler for the endopoint callbackUrl "logA600" as follows.

 class A600Handler(webapp2.RequestHandler): @util.auth_required def post(self): """Process the value of A600 received and return a plot""" logging.info("Received POST to logA600") @util.auth_required def get(self): """Process the value of A600 received and return a plot""" logging.info("Received GET to this logA600") 

MAIN_ROUTES = [('/', MainHandler), ('/ logA600', A600Handler),]

When I answer the timeline map. My logs never display the POST received by my handler with the expected message "Received POST to logA600". Instead, I get the following in my application logs.

2013-07-15 19:52:43.913 /logA600 302 37ms 0kb GlassAPI XX.XXX.XX.XX - - [15/Jul/2013:16:52:43 -0700] "POST /logA600 HTTP/1.1" 302 136 - "GlassAPI" "myapp_on_appengine.appspot.com" ms=37 cpu_ms=0 cpm_usd=0.000032 app_engine_release=1.8.2 instance=0XXXXXXXXXXXXXXXXXXXXXXXXd I 2013-07-15 19:52:43.889 URL being requested: https://www.googleapis.com/discovery/v1/apis/mirror/v1/rest?userIp=xx.xx.xx.xxx

In my test application. I see that the timeline map is arriving successfully. I am looking for help in getting a “RESPONSE” notification subscription to my callbackUrl / logA600 handler.

+4
source share
1 answer

Remove @util.auth_required to def post(self): in /logA600 .

The reason for this is that @util.auth_required checks to see if the current user is allowed, and if not, it redirects them to the OAuth 2.0 thread init URL. Subscription notifications are not authorized requests. They arrive without cookies, as if they were an anonymous user. Upon seeing this, @util.auth_required redirects a notification to the auth page.

+4
source

Source: https://habr.com/ru/post/1491544/


All Articles