I am new to Okta so apologies if my questions are not clear.
So what I want to do is basically parse the JWT token generated by okta and extract the group information of the logged in user associated with it.
I am under the impression that this information should be there in the OidcUser object. I do see user name/email id / token validity etc information inside this object. Unfortunately I can’t see group id which I need for further processing.
@RequestMapping("/")
public String hello(@AuthenticationPrincipal OidcUser user){
StringBuilder sb = new StringBuilder();
for (Map.Entry<String, Object> entry : user.getClaims().entrySet()) {
sb.append(entry.getKey() + ":" + entry.getValue().toString());
sb.append("\n");
}
sb.append("|");
sb.append(user.getClaims());
return sb.toString();
}
@tyty I can’t see that information even in payload. I just want to confirm if I am looking at the right place? Will really appreciate your help on this
You cannot use regex with the “Starts with” filter (only sub-string matching is supported by the “Starts With” option), it will only work if you select “Matches Regex” for the filter instead.
If you want the groups to show up in the ID Token, you need to configure the claim “Include in token type” for ID Tokens to ALWAYS . Otherwise you will need to send your access token to the userinfo endpoint to see the user’s groups