OIDC Connect - Authentication - Access Token
Hi,
I have implemented OIDC Connect authentication in my application and IDP is PingOne. The authentication flow is working as expected. IDP returns both AccessToken and IDToken in the api as part of authentication. However Pega is only saving IDToken to Clipboard pages and AccessToken is not saved to any page on clipboard. How do i retrieve/get the AccessToken in the post authentication activity. After authentication, We have a requirement to call external API by passing AccessToken as parameter to login/authenticate user in external system and retrieve the token from external system and use the token in the subsequent API calls to the external system.
@SReddyR87 - Use the below in Post Authentication Activity to get the Access Token in Clipboard
In my case, I have used the
com.pega.pegarules.pub.connect.oauth2.OAuth2Client oauth2Client =
pega.getServiceUtilsPriv().getOAuth2Client(tools,mAuthServicePage,tools.findPage("OperatorID").getString("pyUserIdentifier"));
// get AccessToken from IDP
String accessToken = oauth2Client.getAccessToken();
// Process the Access Token in jwt format to Json
((PegaAPI)tools).getJWTUtils().processJSONWebToken(accessToken,jwtInstancePage);
// Map the JSON Token Data to StepPage
myStepPage.adoptJSONObject(tools.findPage("AccessTokenPage").getString("AccessToken_JSON"));
Note: Pega also stores Access Token in DB in Table PR_DATA_TOKEN - Access Token, Client ID, Scope etc are stored in this table
Hope this helps !
Good Luck!