Create a gist now

Instantly share code, notes, and snippets.

@Nican / Secret
Created Apr 15, 2012

What would you like to do?
OpenID Simple Openid
package controllers;
import java.util.HashMap;
import java.util.Map;
import org.codehaus.jackson.node.ObjectNode;
import play.libs.F.Promise;
import play.libs.Json;
import play.libs.OpenID;
import play.libs.OpenID.UserInfo;
import play.mvc.Controller;
import play.mvc.Result;
public class Login extends Controller {
public static final Map<String, String> identifiers = new HashMap<String, String>() {
put("google", "");
public static Result getProvider( String providerId ) {
String providerUrl = identifiers.get(providerId);
String returnToUrl = "http://localhost:9000/login/verify";
if (providerUrl == null)
return badRequest("Could not find provider " + providerId);
Promise<String> redirectUrl = OpenID.redirectURL(providerUrl, returnToUrl);
ObjectNode node = Json.newObject();
node.put("url", redirectUrl.get());
//The page is going to be redicted using javascript
return ok(node);
public static Result verifyLogin() {
Promise<UserInfo> userInfoPromise = OpenID.verifiedId();
UserInfo userInfo = userInfoPromise.get();
return ok(Json.toJson(userInfo));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment