c# - How to customize error message of OAuthAuthorizationServerProvider? -
c# - How to customize error message of OAuthAuthorizationServerProvider? -
we using oauthauthorizationserverprovider class authorization in our asp.net web api app.
if provided username , password invalid in grantresourceownercredentials, call
context.seterror( "invalid_grant", "the user name or password incorrect." ); produces next json result:
{ "error": "invalid_grant", "error_description": "the user name or password incorrect." } is there way customize error result? create consistent default error message format used in other parts of api:
{ "message": "some error occurred." } is possible accomplish oauthauthorizationserverprovider?
this how did it.
string jsonstring = "{\"message\": \"some error occurred.\"}"; // work around overcome unknown internal bug. // in future releases of owin, may remove this. context.seterror(new string(' ',jsonstring.length-12)); context.response.statuscode = 400; context.response.write(jsonstring); c# asp.net asp.net-web-api oauth
Comments
Post a Comment