Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
This sample Spiffy project will access your Google Contacts using Scribe, an OAuth library for Java
Java
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
src/main
.classpath
.project
HelloSpiffyOAuth_devmode.launch
LICENSE.txt
README.md
pom.xml

README.md

Spiffy UI - GWT made simple

Hello Spiffy OAuth is an application created from the Spiffy UI Framework project creator, that builds a simple REST application with Apache Maven and uses Scribe by Pablo Fernandez to access Google Contacts data API through OAuth.

Building and Running HelloSpiffyOAuth

This project is built with Apache Maven.

Go to your project's root directory and run the following command:

mvn package jetty:run

This will download the required libraries, including Scribe, build your project, and run it with an embedded Jetty web server. You can access the running application here:

http://localhost:8080

How it works

OAuth is an open protocol to allow secure API authorization in a standard way without sharing usernames or passwords. A user can logs in to a service provider (such as Google) and grant restricted access to a third-party app (such as this sample project) to your private data (such as your Google contacts). Scribe is an OAuth library for Java and supports all major OAuth APIs out of the box, including Google, Facebok, Yahoo, LinkedIn, Twitter and more.

The client for this project is a simple UI that has two buttons: 1. Request access from Google and 2. Get contacts.

When you click the first button, the browser is directed to AuthGoogle, the first of two servlets that use the Scribe library. AuthGoogle will build the OAuthService and fetch a request token from Google. The request token has a visible as well as secret component. The service and full request token are stored in-memory using the visible part of the request token as the key. The servlet will then redirect to Google to allow the user to login and grant access. Because the OAuthService sent a callback to Google, Google will redirect back to this application with the visible part of the request token and a verifier as URL parameters.

When you are returned to this application, the client recognizes that it now has URL parameters and assumes this means you have been granted access. You can then click the second button to get your Google contacts. Using Spiffy UI's REST framework, the client will hit the GoogleContactsServlet passing along the URL parameters received from Google. GoogleContactsServlet retrieves the service and full request token using the request token URL parameter as the key from the in-memory storage, then the service will trade the request token and verifier for an access token. Scribe signs the request to access the Google Contacts data API for your top 200 contacts as JSON. The client then displays them on the page.

Debugging through Eclipse

See Spiffy UI's GWT Dev Mode page for more information.

License

Spiffy UI is available under the Apache License, Version 2.0.

Something went wrong with that request. Please try again.