Blazor oidc doesn't return meaningfull error messages
Mohamed1984 opened this issue · comments
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
I use blazor with openid connect authentication.
I follow microsoft documentation and create an authentication page:
@page "/authentication/{action}"
<RemoteAuthenticatorView Action="@Action">
</RemoteAuthenticatorView>
@code {
[Parameter]
[EditorRequired]
public string? Action { get; set; }
}
If any error happens the authentication page displays general message without details:
"There was an error signing in."
I assume, there should be a way to get error details.
Namely, there should be a way to get error and error_description of oidc spec.
Expected Behavior
The authentication page should display error and error_description fields
Steps To Reproduce
Any blazor app that utilizes oidc authentication and utilize the authentication page will show the same behaviour.
Exceptions (if any)
No response
.NET Version
No response
Anything else?
I digged into asp.net core source to find the problem source.
The problem is in this file:
Specifically in the completeSignIn function (line 258):
async completeSignIn(url: string) {
this.trace('completeSignIn', url);
const requiresLogin = await this.loginRequired(url);
const stateExists = await this.stateExists(url);
try {
const user = await this._userManager.signinCallback(url);
if (window.self !== window.top) {
return this.operationCompleted();
} else {
this.trace('completeSignIn-result', user);
return this.success(user && user.state);
}
} catch (error) {
if (requiresLogin || window.self !== window.top || !stateExists) {
return this.operationCompleted();
}
return this.error('There was an error signing in.');
}
}
You should just adjust the line "return this.error('There was an error signing in.');" to return error details
Thanks for contacting us.
Can you please share more details about what specific error you're trying to see?
Please note, if you are simply curious to see what the actual error is, you can read that information from the querystring from the page you're on.