private string ConvertTokenErrorEnumToString(TokenRequestErrors error)
        {
            if (error == TokenRequestErrors.InvalidClient)
            {
                return(OidcConstants.TokenErrors.InvalidClient);
            }
            if (error == TokenRequestErrors.InvalidGrant)
            {
                return(OidcConstants.TokenErrors.InvalidGrant);
            }
            if (error == TokenRequestErrors.InvalidRequest)
            {
                return(OidcConstants.TokenErrors.InvalidRequest);
            }
            if (error == TokenRequestErrors.InvalidScope)
            {
                return(OidcConstants.TokenErrors.InvalidScope);
            }
            if (error == TokenRequestErrors.UnauthorizedClient)
            {
                return(OidcConstants.TokenErrors.UnauthorizedClient);
            }
            if (error == TokenRequestErrors.UnsupportedGrantType)
            {
                return(OidcConstants.TokenErrors.UnsupportedGrantType);
            }

            throw new InvalidOperationException("invalid token error");
        }
 private string ConvertTokenErrorEnumToString(TokenRequestErrors error)
 {
     return(error switch
     {
         TokenRequestErrors.InvalidClient => OidcConstants.TokenErrors.InvalidClient,
         TokenRequestErrors.InvalidGrant => OidcConstants.TokenErrors.InvalidGrant,
         TokenRequestErrors.InvalidRequest => OidcConstants.TokenErrors.InvalidRequest,
         TokenRequestErrors.InvalidScope => OidcConstants.TokenErrors.InvalidScope,
         TokenRequestErrors.UnauthorizedClient => OidcConstants.TokenErrors.UnauthorizedClient,
         TokenRequestErrors.UnsupportedGrantType => OidcConstants.TokenErrors.UnsupportedGrantType,
         TokenRequestErrors.InvalidTarget => OidcConstants.TokenErrors.InvalidTarget,
         _ => throw new InvalidOperationException("invalid token error")
     });
 /// <summary>
 /// Initializes a new instance of the <see cref="GrantValidationResult"/> class with an error and description.
 /// </summary>
 /// <param name="error">The error.</param>
 /// <param name="errorDescription">The error description.</param>
 /// <param name="customResponse">Custom response elements</param>
 public GrantValidationResult(TokenRequestErrors error, string errorDescription = null, Dictionary <string, object> customResponse = null)
 {
     Error            = ConvertTokenErrorEnumToString(error);
     ErrorDescription = errorDescription;
     CustomResponse   = customResponse;
 }
Esempio n. 4
0
 public TestResourceOwnerPasswordValidator(TokenRequestErrors error, string errorDescription = null)
 {
     _sendError       = true;
     _error           = error;
     _erroDescription = errorDescription;
 }
Esempio n. 5
0
 public TokenExchangeGrantResult(TokenRequestErrors error, string errorDescription)
     : base(error, errorDescription)
 {
     this.IsError = true;
 }
 public IExtensionGrantResultBuilder WithError(TokenRequestErrors error, string errorDescription)
 {
     this.error            = error;
     this.errorDescription = errorDescription;
     return(this);
 }
 private static string ConvertTokenErrorEnumToString(TokenRequestErrors error) =>
 error switch
 {