authorization - Web Api token 过期错误

标签 authorization asp.net-web-api2 owin bearer-token machinekey

我是 Web api 开发的初级。
我已经对我的 web api 项目实现了基于 token 的身份验证。我已将 token 过期时间设置为 14 天。

OAuthOptions = new OAuthAuthorizationServerOptions
        {
            TokenEndpointPath = new PathString("/Token"),
            AccessTokenExpireTimeSpan = TimeSpan.FromDays(14),
            AllowInsecureHttp = true,
            Provider = new AuthorizationServerProvider()
        };

Web 主机中的应用程序主机。
即使 token 过期时间为 14 天。几分钟后,我发送带有 token 的请求,响应带有未经授权的状态代码。

我有关于这个问题的搜索。问题可能与 ISS 中的机器 key 有关。

以下问题,你能回答吗?我真的很想知道他们。
  • ISS 中的机器 key 是否对 token 进行编码或解码?
  • 我怎样才能得到机器 key ?
  • 在 web.config 文件中写入机器 key 是否安全?

  • 我该如何解决问题?有人可以帮我吗?

    感谢您的关注。
    此致。

    最佳答案

    您可以在 IIS 中获取机器 key 。
    您必须在 web.config 文件中的 system.web 标签下添加机器 key 。

    关于authorization - Web Api token 过期错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41358556/

    相关文章:

    android - Retrofit 是否缓存授权请求

    c# - 自定义主体对象与 ASP.NET 中的成员资格 API?

    ruby-on-rails - 具有权威的 View 中的属性级别授权

    c# - 如何捕获 JsonConverter 属性中抛出的异常?

    owin - Katana Webserver 找不到 clientSecret

    asp.net-core - 在.Net core中共享默认的OWIN token

    首次 Facebook Connect 授权/登录后 iPhone 应用程序崩溃

    c# - WebAPI 2 项目中 Auth0 的最新设置

    azure - 使用 Azure 应用服务轻松身份验证 + Azure AD B2C 是否可以保护单个 Web API 并让多个 native 应用程序使用它?

    c# - OpenId 身份验证跳过 "Please wait..."屏幕