Skip to content

fix: improve error messaging for invalid redirect_uri OAuth error#4

Open
quantcode-agent[bot] wants to merge 1 commit into1.xfrom
quantcode/job-job-70e1cc23
Open

fix: improve error messaging for invalid redirect_uri OAuth error#4
quantcode-agent[bot] wants to merge 1 commit into1.xfrom
quantcode/job-job-70e1cc23

Conversation

@quantcode-agent
Copy link
Copy Markdown

Summary

  • Detects invalid_redirect_uri OAuth errors specifically (by checking the error code and description)
  • Replaces the generic "Authorization Error" message with a clear, actionable message that explains the issue and suggests using the Manual Token option
  • Provides a clickable link to https://dashboard.quantcdn.io/profile where users can generate a personal access token

Changes

src/Controller/OAuthController.php

  • Added use Drupal\Core\Render\Markup import
  • Added detection logic for redirect_uri-related OAuth errors (stripos on error description + exact match on error code)
  • When a redirect_uri error is detected, displays: "Your MCP client's redirect URI isn't registered for this OAuth app. Try the Manual Token option instead — generate a personal access token at [link] and paste it into your client."
  • Non-redirect_uri errors continue to show the existing generic message
  • Wrapped HTML message in Markup::create() to ensure the link renders as clickable HTML

Assumptions

  • The OAuth error parameters come via query string (error and error_description) as per OAuth 2.0 spec
  • The error code invalid_redirect_uri or description containing "redirect_uri" are sufficient signals to detect this condition
  • The hardcoded URL https://dashboard.quantcdn.io/profile is the correct location for personal access token generation
  • Using Markup::create() is appropriate here since the URL is hardcoded (not user-supplied), so there's no XSS risk

Closes #1

When OAuth fails with an invalid redirect_uri, users now see a helpful,
actionable message that explains the issue and directs them to use the
Manual Token option with a link to generate a personal access token.

Closes #1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve error messaging for invalid redirect_uri OAuth error

0 participants