4

Question:

Is there any method for retrieving the current user's OpenId Connect (OIDC) Id Token via apex?

Background Context / Goal:

My goal is to set up Single logout for a salesforce community that is connected to an OpenID Connect Okta Authorization server.

Previous Attempts

I attempted following Salesforce Documentation 'Configure OpenID Connect Settings for Single Logout Where Salesforce Is the Relying Party'. The Auth. Provider Custom logout url was not working as expected for the community (when we attempt to logout via this url, the id_token_hint does not get passed to the logout endpoint as Okta expects it to).

Current Attempt:

I am trying to make a custom component that has an anchor element with an href set to the single logout get request in the Okta provided format, but there doesn't seem to be a way to retrieve the id token via salesforce apex:

GET https://{baseUrl}/logout?id_token_hint=${id_token}&post_logout_redirect_uri=${post_logout_redirect_uri}&state=${state}
4
  • Have you considered trying AuthToken class? I don't have time to test at the moment but checkout the getAccessToken(authProviderId, providerName) method. (developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/…) Commented Jun 8, 2021 at 17:20
  • @Sarah Ganci: Did you ever find a solution for this? I'm also looking for a way to get the id_token, but can't find one so far.
    – Christoph
    Commented Aug 4, 2021 at 9:44
  • The AuthToken class only returns the access token, which does not help in this scenario.
    – Christoph
    Commented Aug 4, 2021 at 10:18
  • +1. Assuming by the lack of response that this is not possible in Apex. Seems to be quite a restriction.
    – acarlon
    Commented Sep 17, 2021 at 5:24

0

You must log in to answer this question.