Skip to content

Instantly share code, notes, and snippets.

@chamerling
Created December 12, 2011 10:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chamerling/1466592 to your computer and use it in GitHub Desktop.
Save chamerling/1466592 to your computer and use it in GitHub Desktop.
OAuth GitHub and Play!
/**
* Github call this as callback
*/
public static void callback(String code) {
System.out.println("Just get code from github : " + code);
WSRequest request = WS
.url("https://github.com/login/oauth/access_token");
request.setParameter("client_id", CLIENT_ID);
request.setParameter("client_secret", CLIENT_SCRET);
request.setParameter("code", code);
System.out.println("Trying to get oauth from github...");
play.libs.WS.HttpResponse response = request.post();
System.out.println("Response status = " + response.getStatus());
System.out.println("Response body = " + response.getString());
String oauth = "quickhubapp://oauth?" + response.getString();
render(oauth);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment