Question

I am trying to use the mirror-api-python-cli command line interface to send timeline cards from Raspberry Pi to Google Glass. I am able to complete the first step which uses the code in get-credentials.py to connect to Google with my application client-id and secret. This code prompts to go to an authorisation URL to obtain a code and upon entering the code it does go on to correctly populate a credentials file with authentication information including access_token and refresh_token.

I am then running the code in the second file, send-to-glass.py, to pass a 'hello world' message to the Google Glass timeline. I am receiving no error message and yet nothing is received by the Glass.

I have created a separate web client for the application using the Google playground and that is able to send cards to the timeline so I know there is no problem on the Google application side.

I have also done a print of the insert_timeline_item call and I think that might be giving a clue as to where the issue lies. The last name value pair in the json response is selfLink which has a url of https://www.googleapis.com/mirror/v1/timeline/xxxxxx where xxxxxx is the id value. If I follow this URL then I get the following:

{ "error": { "errors": [{ "domain": "global", "reason": "required", "message": "Login Required", "locationType": "header", "location": "Authorization" }], "code": 401,   "message": "Login Required" }}

---------- UPDATE ----------

I used CURL with a fresh access token, as suggested by Jenny. I must admit I am not familiar with CURL and so it took a few tries to get it to work. First the address was not resolving, so I added www in front of googleapis, then it was complaining that SSL was required so I added https in front, then it complained about the certificate so I added the -k parameter and finally it was trying to resolve Bearer and my access tokens as addresses so I used double quotes instead of single quotes. Please feel free to chuckle at the noob here but possibly this may help someone in the future!

My final curl command looked like this:

{ curl -H "Authorization: Bearer MY-ACCESS-TOKEN" https://www.googleapis.com/mirror/v1/timeline -k }

The result came back with a whole load of json, with what looked like all of the timeline cards I tried to send from the Raspberry Pi. I won't list all the entries, but the top of the json looks like this:

{"kind": "mirror#timeline", "nextPageToken": "LONG-STRING-OF-CHARACTERS",
 "items": [
 {
  "kind": "mirror#timelineItem",
  "id": "ITEM-ID",
  "selfLink": "https://www.googleapis.com/mirror/v1/timeline/ITEM-ID",
  "created": "2014-04-19T01:40:40.597Z",
  "updated": "2014-04-19T01:40:40.597Z",
  "etag": "1397871640597",
  "text": "Hello World",
  "notification": {
   "level": "DEFAULT"
  }
 },
 { ... }

So it would appear that somehow the cards are getting to my timeline and yet they are not being delivered to the Glass. As a reminder, using a web client in the playground against the same project I was able to see cards come through to Glass.

Was it helpful?

Solution

So this is a little embarrassing, I have discovered exactly what the problem was. This whole exercise is related to a science fair project my son is doing. He had been programming the Raspberry Pi through WebIDE logged on through his Google Account. I had set up the project to access Glass through my Google account in a separate Chrome browser. Each time I ran get-credentials.py on the Raspberry Pi and it directed me to copy the URL into the browser for approval, I was doing so in my son's browser with his Google account. The credentials were being saved correctly and cards were populating a timeline correctly, but all against my son's Google account and he has no Glass!

I re-ran get-credentials.py, ran the URL in a browser session associated with my own account. Copied the code back to the Pi and now send-to-glass.py works perfectly. My son thinks I'm an idiot and is getting plenty of laughs out of it, but I am pleased to report everything is now working.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top