Skip to content

Instantly share code, notes, and snippets.

@ArnauMrJeff
Last active September 7, 2020 15:54
Show Gist options
  • Save ArnauMrJeff/b9dc5f3dd48a77d8922177b4c3810b24 to your computer and use it in GitHub Desktop.
Save ArnauMrJeff/b9dc5f3dd48a77d8922177b4c3810b24 to your computer and use it in GitHub Desktop.
Apple ID Sign In: AppleAuth
private void appleAuth(String authorizationCodeSentByApp, String keyIdentifierSentByApp) throws Exception {
var token = generateJWT();
// Http Requests Client
var tokenResponse = httpClient.getTokenResponse("CLIENT_ID", token, "authorization_code", authorizationCodeSentByApp);
var idToken = tokenResponse.getIdToken();
// We had until here
var claims = getClaims(keyIdentifierSentByApp, idToken);
var iss = claims.get("iss", String.class);
var aud = claims.get("aud", String.class);
var exp = claims.get("exp", Date.class);
var iat = claims.get("iat", Date.class);
var appleIdentifier = claims.get("sub", String.class);
var atHash = claims.get("at_hash", String.class);
var authTime = claims.get("auth_time", Long.class);
var email = claims.get("email", String.class);
var emailVerified = claims.get("email_verified", String.class);
// Do with params what you need to do
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment