public
Last active

  • Download Gist
Application.java
Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
@SuppressWarnings("serial")
public static final Map<String, String> identifiers = new HashMap<String, String>() {
{
put("google", "https://www.google.com/accounts/o8/id");
}
};
 
public static Result auth() {
Logger.debug("authenticate");
String providerId = "google";
String providerUrl = identifiers.get(providerId);
String returnToUrl = "http://localhost:9000/login/verify";
 
if (providerUrl == null) {
return badRequest("Could not find provider " + providerId);
}
 
Map<String, String> attributes = new HashMap<String, String>();
attributes.put("Email", "http://schema.openid.net/contact/email");
attributes.put("FirstName", "http://schema.openid.net/namePerson/first");
attributes.put("LastName", "http://schema.openid.net/namePerson/last");
 
Promise<String> redirectUrl = OpenID.redirectURL(providerUrl, returnToUrl, attributes);
return redirect(redirectUrl.get());
}
 
public static Result verify() {
Logger.debug("verifyLogin");
Promise<UserInfo> userInfoPromise = OpenID.verifiedId();
UserInfo userInfo = userInfoPromise.get();
JsonNode json = Json.toJson(userInfo);
return ok(json);
}
routes
1 2
GET /login/auth controllers.Application.auth()
GET /login/verify controllers.Application.verify()

can someone briefly describe the details.It's showing error..what is Logger.debug("authenticate"); ,

Logger is play.Logger. Just add:

import Play.Logger;

to make it work.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.