Show human-readable error messages for known OAuth provider errors#5769
Open
carmenlau wants to merge 5 commits into
Open
Show human-readable error messages for known OAuth provider errors#5769carmenlau wants to merge 5 commits into
carmenlau wants to merge 5 commits into
Conversation
8c8154d to
d44d901
Compare
tung2744
reviewed
Jun 12, 2026
Comment on lines
+291
to
+309
| {{ $oauth_error_code := .Error.info.error }} | ||
| {{ $oauth_provider_type := .Error.info.provider_type }} | ||
| {{ if eq $oauth_error_code "access_denied" }} | ||
| <span>{{ include "v2.error.oauth-access-denied" nil }}</span> | ||
| {{ else if eq $oauth_error_code "temporarily_unavailable" }} | ||
| <span>{{ include "v2.error.oauth-temporarily-unavailable" nil }}</span> | ||
| {{ else if eq $oauth_error_code "server_error" }} | ||
| <span>{{ include "v2.error.oauth-server-error" nil }}</span> | ||
| {{ else if and (eq $oauth_provider_type "iamsmart") (eq $oauth_error_code "D40000") }} | ||
| <span>{{ include "v2.error.oauth-iamsmart-cancelled" nil }}</span> | ||
| {{ else if and (eq $oauth_provider_type "iamsmart") (eq $oauth_error_code "D40001") }} | ||
| <span>{{ include "v2.error.oauth-iamsmart-rejected" nil }}</span> | ||
| {{ else if and (eq $oauth_provider_type "iamsmart") (eq $oauth_error_code "D40002") }} | ||
| <span>{{ include "v2.error.oauth-iamsmart-failed" nil }}</span> | ||
| {{ else if and (eq $oauth_provider_type "iamsmart") (eq $oauth_error_code "D40003") }} | ||
| <span>{{ include "v2.error.oauth-iamsmart-timeout" nil }}</span> | ||
| {{ else }} | ||
| <span>{{ include "v2.error.oauth-error" (dict "error" $oauth_error_code "error_description" .Error.info.error_description) }}</span> | ||
| {{ end }} |
Contributor
There was a problem hiding this comment.
Instead of handling provider specific error code here, do you think we can have a error translation in the oauthrelyingparty code?
Contributor
Author
There was a problem hiding this comment.
I think the translation and copywriting should be owned by the Auth UI layer. How about if I introduce an Error Category concept in oauthrelyingparty? And providers map their proprietary error codes to a set of defined categories, and the Auth UI template handles each category without any provider-specific logic.
Let me update the code to reflect that.
62f99ef to
971a9b8
Compare
Add provider_type to OAuthError details so the template can gate iamsmart-specific error codes. Map known RFC 6749 codes (access_denied, temporarily_unavailable, server_error) and iamsmart D-codes (D40000–D40003) to user-friendly messages; unknown codes fall back to the raw error string. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Introduce ErrorCategory type and constants in oauthrelyingparty. Providers set Category on ErrorResponse when constructing it, so authgear-server reads the category directly without a separate interface. The Auth UI template handles known categories and RFC 6749 codes to display human-readable error messages. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
971a9b8 to
c04a6db
Compare
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
c04a6db to
b1edd0c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ref DEV-3649