Reputation: 1616
I'm having some sticking points with how to do something in Glass. The current flow I'm thinking of for my application is almost identical to the existing Mirror API flow for things like Evernote or Sharing photos. Except for one major caveat, the first thing a user would do with my Glassware is to search from something and then be presented with a list of possible results. Then they could select one of those and post it, along with a comment to my service.
To post to me, they will need to be authenticated or at least somehow provide identity information. The two ways I came up with to do this is to either provide a QR code with an API key tied to that user and scan that with glass so that it can store and send that key with the request, or to use the Mirror API somehow. If the user logs in on my end, then goes through OAuth with Google, I can immediately subscribe to some sort of custom event or add a Contact for posting updates through my Glassware or something, and Google will give me the user identity with the callback. However, I was planning on creating an immersion to allow the user to page between results rather than inserting static cards and don't know how to start a Mirror API call from there.
The QR code thing seems hacky, though there is precedent with the WiFi Settings...but it just doesn't seem appropriate. I'd much rather go through the mirror API, any ideas?
I'll accept that the capability just doesn't exist yet and I should file or expand an existing issue...but I just wanted to check beforehand how everyone was dealing with this now.
Upvotes: 3
Views: 1031
Reputation: 161
You might need to insert Mirror account from Mirror API. Like this: http://goo.gl/DVggO6
and then you will need to retrieve accounts from your GDK using Android's account manager. You can add as many details as you like in 'user data' field while inserting mirror account.
GDK Code will be like this:
public static String fetchAccountMailId(Activity c) {
String accountEmailId = null;
AccountManager manager = AccountManager.get(c);
Account[] list = manager
.getAccountsByType("account-name");
for (Account acct : list) {
accountEmailId = acct.name;
break;
}
return accountEmailId;
}
Upvotes: 0
Reputation: 161
https://developers.google.com/glass/develop/gdk/authentication might help now. Though it is not explanatory enough on how to create service auth page using PHP.
Upvotes: 1
Reputation: 13954
First off, about sharing authentication information for your service with a GDK Glassware:
There's no clean, officially recommended way to do this right now, but it is something that the Glass team is actively working on for a future release. An early version is already in use by the Strava Glassware.
It will provide a REST API. Any authentication information that you post to this web service will be exposed to your GDK Glassware via AccountManager
.
Next, in regards to using Mirror API from Glass: There's no great way to do this either right now. It will be easier in the future, for example via the auth flow I mention above. But, using both GDK and Mirror is a at the edge of what the Glass team expects developers to use since it adds so much complexity. If there's only a small gap on the Mirror API, please help close that gap by filing a feature request in the official issue tracker.
Upvotes: 2
Reputation: 187
You can bring up a web view in the Android app, loading the authentication URL of your web service. After the authentication completes, the web service can put the auth token in the redirection url, then your Android app can intercept the redirect url loading with shouldOverrideUrlLoading.
You may need to do something extra to make this mechanism more secure.
Upvotes: 0