Skip to content

AuthorizeUrlGenerator does not URL-encode redirect_uri, state and other query values #2081

Backlog

Description

@omkarbandikatte

Reproducible in:

The Slack SDK version

slack_sdk 3.48.0 (also main at 80f2f22)

Python runtime version

Python 3.13.18

OS info

macOS (not OS-specific)

Steps to reproduce:

AuthorizeUrlGenerator.generate() and OpenIDConnectAuthorizeUrlGenerator.generate() put state, redirect_uri, team, nonce and the other values into the query string without URL-encoding them. A value that contains &, ?, = or + changes the meaning of the generated URL.

from urllib.parse import parse_qs, urlparse

from slack_sdk.oauth import AuthorizeUrlGenerator

redirect_uri = "https://example.com/slack/oauth_redirect?tenant=acme&env=prod"
state = "a+b/c=="  # for example a base64 value issued by a custom OAuthStateStore

generator = AuthorizeUrlGenerator(
    client_id="111.222",
    scopes=["chat:write"],
    redirect_uri=redirect_uri,
)
url = generator.generate(state=state)
params = parse_qs(urlparse(url).query, keep_blank_values=True)

print(url)
print(params["redirect_uri"])
print(params["state"])
print(params.get("env"))

Expected result:

The URL carries the values that were passed in:

['https://example.com/slack/oauth_redirect?tenant=acme&env=prod']
['a+b/c==']
None

Actual result:

https://slack.com/oauth/v2/authorize?state=a+b/c==&client_id=111.222&scope=chat:write&user_scope=&redirect_uri=https://example.com/slack/oauth_redirect?tenant=acme&env=prod
['https://example.com/slack/oauth_redirect?tenant=acme']
['a b/c==']
['prod']
  • redirect_uri is cut at its first &, and the rest (env=prod) becomes a separate parameter of the authorize request.
  • The + in state is read as a space, so the state that comes back in the callback no longer matches the one that was issued.

OpenIDConnectAuthorizeUrlGenerator behaves the same way, including for nonce.

I have a fix with tests and will open a pull request for it. It percent-encodes each value and keeps :, / and , as they are, so the URLs generated for values without reserved characters do not change.

Requirements

For general questions/issues about Slack API platform or its server-side, could you submit questions at https://my.slack.com/help/requests/new instead. 🙇

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

Activity

  1. added
    bug
    on Nov 24, 2026
  2. added this to the 3.48.1 milestone on Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugoauth

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions