Errors in redirect with id_token for OpenID implicit flow

We are using Okta with an OpenID implicit flow to get an id_token. The particular API call we are making to Okta is:](

The callback end point is properly authorized. However the returned redirect looks like this:

Notice that there is a # before the id_token. Logically this should have been a ? to indicate the start of the URL parameters. By HTML redirect semantics, the user agent (browser) does not pass anything after the # to the redirect. So we never see the id_token in the back end. The id_token itself is correct – we have manually parsed it. It is just the URI that seems to be malformed.

Any help would be appreciated.

Hi @prasanna

When accessing the /authorize endpoint, if you are not specifying the response_mode or if response_mode is set to “fragment”, then the resource requested will be returned as fragment “#” instead of query “?”. As per the article here, unfortunately, JWT tokens can not be returned as query parameters, only as fragment or POST attributes.

Thanks. But since POSTs cannot be redirected, and fragments are ignored during redirect, how can you use the callback to get the authenticated user’s id_token? What is the proper flow to do this?

You can capture the ID token on the /callback endpoint and, once it’s evaluated and the local session is created, you can redirect to your application’s dashboard with the local session active.

An alternative method would be to do authorization code flow, capture the code from the GET request on /callback endpoint and then send it to /token endpoint in Okta to retrieve the JWT tokens.

The issue with the first approach is that since Okta returns with a redirect URL, the user agent never forwards the fragment. The callback endpoint only sees the first part of the URI up to the #
The issue with the second is similar. We can complete the auth flow and get the auth code. But the Okta /token endpoint can only accept a POST. Ideally after getting the auth token, we would want to do a redirect back to the user agent to go back to Okta’s /token endpoint. But you cannot redirect POST parameters.