【问题标题】:How can i change expiry_in parameter of token in oauth2 with django rest如何使用 django rest 更改 oauth2 中令牌的 expiry_in 参数
【发布时间】:2018-08-08 22:15:39
【问题描述】:

卷曲 -X 发布 -d "grant_type=密码&用户名=&密码="-u":" http://localhost:8000/o/token/

我得到了访问令牌:

{ "access_token": "bWT0hgV6nXdvwIXuk7SREtZYWGWJOp", “expires_in”:36000,
"token_type": "承载者",
“范围”:“读写组”, "refresh_token": "5DUMuBWIHdBMFyGDKeJidCR6gD0Ftc" }

我想把“expires_in”参数改成2000。

【问题讨论】:

  • 请详细说明您的问题

标签: django oauth-2.0 django-rest-framework


【解决方案1】:

您似乎在应用程序中生成了令牌。重点关注生成token的方法。应该有一些设置,如

payload = {
    "iss": "example.com",
     "iat": int(time.time()),
     "exp": int(time.time()) + 2000,
     "aud": "www.example.com",
     "sub": account['_id'],
     "username": username,
     "scopes": ['open']
}

,您只需设置exp 2000s 之后的时间。

如果您使用第三方应用程序,您可以尝试查找有关过期或令牌生命周期的配置。如果没有 UI 配置,应该有一些配置文件来设置它。更糟糕的是,您可以尝试在源代码中找到"exp" 并手动设置值。

【讨论】:

    猜你喜欢
    • 2014-01-08
    • 1970-01-01
    • 2021-03-10
    • 2019-06-20
    • 2020-07-31
    • 2018-01-29
    • 2021-10-03
    • 2019-06-28
    • 2015-04-29
    相关资源
    最近更新 更多