Slack API · error code

Slack error bad_redirect_uri: redirect_uri does not match the original request

ConfigurationHTTP 200Tokens & authentication

Last verified against Slack API reference - chat.postMessage errors

What Slack returns
Value passed for redirect_uri did not match the redirect_uri in the original request.

What error bad_redirect_uri means

The redirect_uri you sent to oauth.v2.access differs from the one used when the user was sent to Slack's authorize page. Slack says "Value passed for redirect_uri did not match the redirect_uri in the original request." The two must be identical, character for character.

The method's notes point out a trap: "while redirect_uri is optional, it is required if your app passed it as a parameter to oauth/authorization in the first step of the OAuth flow." So if your Add to Slack link includes a redirect_uri and your exchange leaves it out, or sends a different value, the install fails here.

Small differences count: http versus https, a trailing slash, www versus no www, an extra query parameter, or encoding differences. Slack's guide also requires that "The redirect_uri must use HTTPS." Different environments that build the URL from different base URLs cause most mismatches.

What it looks like

Authorize:  redirect_uri=https://app.example.com/slack/oauth/callback
Exchange:   redirect_uri=https://app.example.com/slack/oauth/callback/

{"ok": false, "error": "bad_redirect_uri"}

Why it happens

  • The authorize link passed a redirect_uri but the token exchange did not send one.
  • The two values differ by scheme, host, trailing slash, path or query string.
  • Different environment variables were used to build the two URLs.
  • A proxy or load balancer changed the scheme or host seen by your app.

How to fix Slack error bad_redirect_uri

  1. 1Log both redirect_uri values and compare them byte for byte.
  2. 2Build the URL from one config value and use it in both the authorize link and oauth.v2.access.
  3. 3Either send redirect_uri in both steps or in neither (relying on the URL configured in app settings).
  4. 4Use HTTPS and make sure the URL is listed under Redirect URLs in your app's OAuth settings.

How to stop it recurring

Define the OAuth callback URL once per environment and generate both the authorize link and the exchange call from it. Add an install test per environment, since redirect mismatches usually appear only after a domain or proxy change. Log both values whenever the exchange fails.

Official reference: Slack API reference - chat.postMessage errors. See all Slack error codes or the Slack limits and quotas.

Related codes

Error bad_redirect_uri - quick answers

What does Slack error bad_redirect_uri mean?

The redirect_uri you sent to oauth.v2.access differs from the one used when the user was sent to Slack's authorize page. Slack says "Value passed for redirect_uri did not match the redirect_uri in the original request." The two must be identical, character for character.

How do I fix Slack error bad_redirect_uri?

1. Log both redirect_uri values and compare them byte for byte. 2. Build the URL from one config value and use it in both the authorize link and oauth.v2.access. 3. Either send redirect_uri in both steps or in neither (relying on the URL configured in app settings). 4. Use HTTPS and make sure the URL is listed under Redirect URLs in your app's OAuth settings.

Stop debugging Slack by hand

Connect the channel through Conferbot: tokens, webhooks and retries are handled, failures show as readable status.