A library for making OAuth with Google easier!
GlassAuth is an easy to use library designed to make authentication with a Google Account easier. Have you seen applications using QR codes to send OAuth tokens to Glass? That's not quite a good idea. GlassAuth makes use of Google's OAuth for Devices. All the user has to do is enter a code here.
GlassAuth takes care of making a slick sign in process (with UI and all), and makes authorized HTTPS requests in just a few lines.
It is expected that you have a project setup at the Google Developer Console, with the Google+ API enabled and OAuth certificates generated.
How to Use
- Clone the source of this application and include it as a library in your Glass project.
- In the GlassAuth library, go to
src/com/victor/kaiser/pendergrast/auth/setup/AuthConstants.javaand set the
CLIENT_SECRETaccording to what you generated at the Google Developer Console.
- Use manifest merger, or declare the
AuthActivityin your manifest like so:
<activity android:name="com.victork.kaiser.pendergrast.auth.AuthActivity" />
- In your UI, have the user sign in by starting an
- Later, you can confirm the user is signed in by calling
AuthHttpsRequestto make authenticated requests. You can add JSON parameters and change the HTTP request method to whatever you need. The
OnResponseListeneryou specify will be called when a response is received. AuthHttpsTask request = new AuthHttpsTask(context, url, json, "POST", listener); request.execute();
onResponse(boolean success, String response) method in
OnResponseListener may not behave as you expect.
success only indicates if the HTTPS request returned 200 "good" code.
Response is simply the response from the server.