【问题标题】:How to make my authentication token not expire?如何使我的身份验证令牌不会过期?
【发布时间】:2016-04-03 12:45:01
【问题描述】:

我正在使用 itsdangerous 来为我的 API 创建身份验证令牌。但是,在我的移动应用程序中,我注意到我的令牌经常过期。这是令牌生成-

def generate_auth_token(self, expiration=None):
    s = Serializer(app.config['SECRET_KEY'])
    return s.dumps({'id': self.id})

我也试过-

def generate_auth_token(self, expiration=None):
    s = Serializer(app.config['SECRET_KEY'], expires_in=expiration)
    return s.dumps({'id': self.id})

但是,我的令牌大约每 10-20 分钟定期到期。

【问题讨论】:

    标签: python authentication flask token restful-authentication


    【解决方案1】:

    我认为你不应该超过令牌过期时间。

     def generate_auth_token(self, expiration=None):
           s = Serializer(app.config['SECRET_KEY'])
           return s.dumps({'id': self.id})
    

    你也可以看到https://jwt.io/创建token。

    【讨论】:

      猜你喜欢
      • 2021-01-10
      • 2015-11-12
      • 1970-01-01
      • 1970-01-01
      • 2016-04-04
      • 1970-01-01
      • 1970-01-01
      • 2016-09-27
      • 2021-01-29
      相关资源
      最近更新 更多