错误代码常量

Constants for Error Codes

构建 OAuthAuthorizationServerProvider class 时,必须能够 return 失败状态的错误代码。根据 RFC,这些应该是 invalid_requestunauthorized_client

目前,我手写了这些:

context.SetError("access_denied", "Invalid Username or Password");

是否有内置的 .Net class 提供这些代码作为 system/Packages 中的常量?

Is there a built-in .Net class that provides these codes as constants within the system/Packages?

没有。 Microsoft.Owin.Security.OAuth 包(OAuth2 授权服务器中间件所在的位置)有一个 OAuthConstants class 公开了您要查找的错误代码,但它是内部的:https://github.com/jchannon/katanaproject/blob/master/src/Microsoft.Owin.Security.OAuth/OAuthConstants.cs#L49-L57

也就是说,没有什么能阻止您创建自己的常量 class。