← back

The Invisible Handshake: Troubleshooting the CIAM Callback

The Callback Paradox

In Customer Identity and Access Management (CIAM), the “callback” is not a function call—it is a journey.

The most fundamental misunderstanding is the belief that the Authorization Server (often called the AS, or the Identity Provider / IdP) “pushes” data directly into your application. It does not. The AS redirects the user’s browser to a pre-registered URL. The browser is the courier; the server is merely the dispatcher.

In CIAM, the callback is a redirect, not an API call. If you treat it as code-to-code communication, you will fail in production because you are ignoring the browser's role as the intermediary.

The Mechanics of the Redirect

In a standard flow, your application sends the user to the AS. The AS verifies the user and then redirects the browser back to your Callback URL.

This is where the dreaded redirect_uri_mismatch occurs. The AS only delivers the payload if the requested URL matches the registered URI exactly. This is not a bug; it is the primary security mechanism preventing authorization codes from being intercepted by malicious actors.

The Federation Trap: Who is the Station?

The most dangerous point of failure occurs during Identity Federation. This is when your Authorization Server (e.g., Auth0) trusts another external IdP (e.g., Google, Azure AD, or a corporate Okta instance) to verify the user.

I recently worked with a team where the identity flow was completely broken. They had configured Auth0 as their central Authorization Server, but when setting up the federation with their external IdP, they provided their application’s callback URL as the destination.

They were expecting the external IdP to send the user directly back to their app.

This is the architectural equivalent of mailing a letter to your house and expecting the post office to deliver it to your desk—without the post office ever knowing where your house is. In a federated flow, the external IdP must send the user back to the Authorization Server (Auth0), not the application. The AS then processes that signal and performs its own second redirect to the app.

In federation, the external IdP's callback URL must be the endpoint of your Authorization Server. If you point the external IdP directly at your application, you break the chain of trust and the session will never initialize.

OAuth2 vs. OIDC: The Payload Divide

Even when the direction is correct, the payload can be wrong. OAuth2 and OIDC use the same redirect mechanism, but they deliver different things.

OAuth2 is for Authorization

It provides a key to access a resource (this references the Access Token). It says: “This person is allowed to touch this data.”

OIDC

OIDC is for Authentication. It is designed to prove identity, this is what the ID Token is for. It says: “This is specifically Sam Clark, and here is his unique identifier.”

OAuth2 gives you a key; OIDC gives you a passport. Confusing a key for a passport is the most common cause of "invalid token" errors in CIAM.

Stop Debugging Code, Start Debugging Direction

When a flow fails, stop staring at the logs and start looking at the map.

If you understand that the browser is the courier and the redirect is the handshake, the invisible process becomes visible. In the end if you can figure out these basics, you’ve kind of set yourself up for success when troubleshooting CIAM IDP flows