I'm trying to use Keycoak as identity provider
for SSO
.
Following salesforce help example , I managed to create the login page, redirection, and the user can login succesfulyy , however I wasn't able to obtain access token.
I tried the following inside AutocreatedRegHandler
:
string accessToken = Auth.AuthToken.getAccessToken(AuthProviderId, 'Open ID Connect');
System.debug('accessToken :' + accessToken );
but accessToken
returns null
hence authentication
is not successful.
I also added Auth provider's scoop but nothing changed.
How to get access_token
?
Best Answer
To get an
access token
fromKeyclaok
, aPOST
method toKeyCloak end point
was used, it includes theclient secret
,client id
,username
and thegranttype
.Follow the example below as well as check more info on KeyCloak's docs