Resource Server jwt Sample code

From ESS-WIKI
Jump to: navigation, search
  • Restful API for idTokenString from Openid Server
Base64.Decoder decoder = Base64.getDecoder();
String[]  tokenParts  = idTokenString.split("\\.");
String tokenpayload = new String(decoder.decode(tokenParts[1]), "UTF-8");
JSONObject jsonObj = new JSONObject(tokenpayload);
String username = jsonObj.getJSONObject("name").toString();
String email = jsonObj.getJSONObject("email").toString();