0
votes

I got the code by calling this in wso2 idp server. "https://localhost:9443/oauth2/authorize/?response_type=code&client_id=xxxxxxxxxx&scope=openid profile&state=xy25q6ghkz&redirect_uri=http://localhost/gatewaytest/Home/WsoCallBack"

Then i received the code to my application after user login. Then how i get the user details by this code. What is the WSO2 endpoint to get the user by code after login the user.

1

1 Answers

1
votes
  1. Retrieve the id token (since you have passed openid scope)invoking the token endpoint.
curl -k -X POST https://localhost:9443/oauth2/token -H 'Authorization: Basic <base64encoded(client_id:client_secret)>' -H 'Content-Type: application/x-www-form-urlencoded' -d 'grant_type=authorization_code&code=<authorization_code>&redirect_uri=<callback_url>'

Once the id_token is decoded (use https://jwt.io/) you can see user information.

  1. Get the access token from the above request and invoke userinfo endpoint
curl -k -H "Authorization: Bearer <Acess_token>" https://localhost:9443/oauth2/userinfo?schema=openid

Refer following for more details.

  1. https://is.docs.wso2.com/en/latest/learn/basic-client-profile-with-playground/
  2. https://medium.com/identity-beyond-borders/generating-access-tokens-using-wso2-identity-server-4d8c084a3bf5
  3. https://www.youtube.com/watch?v=Bj8ob_I_DKo