Created
December 13, 2010 21:19
-
-
Save ryanswanstrom/739618 to your computer and use it in GitHub Desktop.
This class shows some code for the callback of a Janrain (formerly Rpx Now) login using the Play Framework
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package controllers; | |
import com.google.gson.JsonElement; | |
import play.Play; | |
import java.util.Properties; | |
import play.libs.WS; | |
import play.libs.WS.WSRequest; | |
import play.mvc.Controller; | |
/** | |
* This class is for the callback of a Janrain(formerly RPXNow) login. | |
*/ | |
public class Login extends Controller { | |
public static void tokenCallback(String token) { | |
Properties p = Play.configuration; | |
// Try the driver | |
String rpxApi = p.getProperty("login.rpx.apiKey"); | |
WSRequest rpxRequest = WS.url("http://rpxnow.com/api/v2/auth_info"); | |
// get RPX | |
rpxRequest.setParameter("token", token); | |
rpxRequest.setParameter("apiKey", rpxApi); | |
JsonElement rpxJson = rpxRequest.get().getJson(); | |
JsonElement profile = rpxJson.getAsJsonObject().get("profile"); | |
String identifier = profile.getAsJsonObject().getAsJsonPrimitive("identifier").getAsString(); | |
welcome(identifier); | |
} | |
public static void welcome(String id) { | |
render(id); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
use getAsJsonPrimitive()