IdentityServer4 icon indicating copy to clipboard operation
IdentityServer4 copied to clipboard

Wrong GrantValidationResult error value

Open HasanAJ opened this issue 8 years ago • 3 comments

I get the wrong error value from GrantValidationResult inside my custom IResourceOwnerPasswordValidator.

Here is the code:

if (roles.Contains(Constants.ROLES_CLIENT))
{                
    if (!user.PhoneNumberConfirmed)
        {
             context.Result = new GrantValidationResult(TokenRequestErrors.InvalidRequest, "Phone 
             number not verified");
             return;
        }
}

When the token endpoint is called, I get the following:

{
   "error": "invalid_grant",
   "error_description": "Phone number not verified"
}

I tried all types of TokenRequestErrors but I always get invalid_grant.

I also try to change this value using the following line but it also doesnt work: context.Result.Error = "whatever";

HasanAJ avatar Feb 28 '18 20:02 HasanAJ

I think I found it, this line shouldn't use OidcConstants.TokenErrors.InvalidGrant but use the resourceOwnerContext.Result.Error https://github.com/IdentityServer/IdentityServer4/blob/dev/src/IdentityServer4/Validation/TokenRequestValidator.cs#L427

Can I submit a PR?

user1336 avatar Mar 01 '18 17:03 user1336

Yes. Thanks.

leastprivilege avatar Mar 02 '18 05:03 leastprivilege

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock[bot] avatar Jan 13 '20 16:01 lock[bot]