Difference between revisions of "Resource Server jwt Sample code"
From ESS-WIKI
Dylan.chang (talk | contribs) (Created page with "*Maven Dependency <pre><code data-lang="xml"><dependencies> <dependency> <groupId>org.keycloak</groupId> <artifactId>keycloak-authz-client</artifactId>...") |
Jonathan.lin (talk | contribs) |
||
Line 1: | Line 1: | ||
− | * | + | *Restful API for idTokenString from Openid Server |
− | <pre> | + | <pre>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();</pre> | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | String | ||
− | |||
− | |||
− | |||
− |
Latest revision as of 09:46, 17 January 2017
- 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();