Not able to get token using Interaction flow

Hi Team,
I am able to login through embedded signin widget and getting Interaction_code and state in query string but i am not able to get token using token API , always getting below error
{
“error”: “invalid_grant”,
“error_description”: “The interaction code is invalid or has expired.”
}

My Curl request is as below
curl --location --request POST ‘https://{oktasubdomain}.okta.com/oauth2/v1/token’ \

–header ‘Accept: application/json’ \

–header ‘Content-Type: application/x-www-form-urlencoded’ \

–header ‘Cookie: JSESSIONID=F7BDD5A34256CB3B949BEC254AE321F5’ \

–data-urlencode ‘grant_type=interaction_code’ \

–data-urlencode ‘redirect_uri=https://mylocalUrl’ \

–data-urlencode ‘code={interaction code getting from query string}’

Hi @m.kumar31

The embedded widget documentation for OIE w/interaction code is,

The embedded auth documentation for OIE w/interaction code is,

Unlike authn + authorization code flow, the Interaction Code flow API does not have public facing documentation and is not supported outside of the Okta SDKs.

You are free to reverse engineer the protocol by observing messaging while using our SDK, but there maybe certain circumstances that returned messages are different from you expect if you are not able to test every possible combination. In addition since the protocol is not documented Okta is free to change the backend implementation without notice.
Currently it is not encouraged, nor supported to try to code to the API directly.

Thank You,

HI @m.kumar31
Try :
curl --location --request POST ‘https://{oktasubdomain}.okta.com/oauth2/v1/token’ \

–header ‘Accept: application/json’ \

–header ‘Content-Type: application/x-www-form-urlencoded’ \

–header ‘Cookie: JSESSIONID=F7BDD5A34256CB3B949BEC254AE321F5’ \

–data-urlencode ‘client_id={ your client id}’ \

–data-urlencode ‘client_secret={ your client secret}’ \

–data-urlencode ‘grant_type=interaction_code’ \

–data-urlencode ‘redirect_uri=https://mylocalUrl’ \

–data-urlencode ‘interaction_code={interaction code getting from query string}’ \

–data-urlencode ‘state={state variable used in original rerequest}’ \

–data-urlencode ‘code_verifier={code_verifier that corresponds to Code challenge used to initialize widget}’

See docs for more info: Interaction Code grant type | Okta Developer

good luck!

2 Likes