We have requirement to generate JWT token based on Custom token profile define for Public OAuth 2.0 Client Registration using Authorization code grant type. Seems like by default for public client registration PEGA is using token profile PegaAAT for token generation, we have updated the token profile PegaAAT but system it is not taking the Custom claims fields defined by us, also as PEGA is using private API to generate
the token, we can not see the inline code.
Can share input how to customized JWT token generated for OAuth 2.0 using Authorization code grant type?
***Edited by Moderator: Pooja Gadige to move from Pega Academy to Product, add capability tag***
I have achieved requirement to generate token by adding additional attributes for Public OAuth 2.0 Client Registration using Authorization code grant type.
Below is the solution details:
1. Enhanced oauth2/v1/token service to call custom activity.
2. This activity call logic to generate additional attributes for "authorization_code" grant_type, otherwise call OOTB activity pzOAuth2GenerateAccessToken.
3. Read request parameters using java and and extract the authorization code param.
4. Open instance of Data-Admin-Security-OAuth2-AuthorizationCode class using the code request param.
5. Get pyUserIdentifier from the opened instance of AuthorizationCode class.
6. Use pyUserIdentifier to extract value from operator table and set the additional attributes from operator table.
7. Call OOTB activity pzOAuth2GenerateAccessToken to generate the token.
8. Extract the token values from param.Response using pxConvertStringToPage.
9. Set additional attributes on the page.
10. Call JSON DT to map the attributes of token. (access_token, refresh_token, token_type, expires_in, additional Attributes [e.g. user_name,email_id])
11. Set Param.response=Param.jsonData. (response contains jwt token along with additional attributes).