简体   繁体   English

如何在Oauth_provider_toolkit Django rest_framework中增加访问令牌的“expires_in”时间?

[英]how to increase “expires_in” time of a access token in Oauth_provider_toolkit Django rest_framework?

how to increase expires_in time of access token (by default it is 36000 i) in Oauth_provider toolkit django rest framework django i want to increase the time so i need help . 如何在Oauth_provider工具包中增加expires_in访问令牌的时间(默认情况下是36000 i)django rest framework django我想增加时间,所以我需要帮助。

should i change the django rest framework code or there is any method available previously so i can use it. 我应该更改django休息框架代码或以前有任何方法可用,所以我可以使用它。

Set in your settings: 在您的设置中设置:

 OAUTH2_PROVIDER = {
        'ACCESS_TOKEN_EXPIRE_SECONDS': 60 * 15,
        'OAUTH_SINGLE_ACCESS_TOKEN': True,
        'OAUTH_DELETE_EXPIRED': True
 }

This will set your expire time to 15 minutes. 这会将您的过期时间设置为15分钟。 The second and third constants are optional, only to show what you can do. 第二个和第三个常量是可选的,仅用于显示您可以执行的操作。

You can override all of these: 您可以覆盖所有这些:

DEFAULTS = {
    'CLIENT_ID_GENERATOR_CLASS': 'oauth2_provider.generators.ClientIdGenerator',
    'CLIENT_SECRET_GENERATOR_CLASS': 'oauth2_provider.generators.ClientSecretGenerator',
    'CLIENT_SECRET_GENERATOR_LENGTH': 128,
    'OAUTH2_SERVER_CLASS': 'oauthlib.oauth2.Server',
    'OAUTH2_VALIDATOR_CLASS': 'oauth2_provider.oauth2_validators.OAuth2Validator',
    'OAUTH2_BACKEND_CLASS': 'oauth2_provider.oauth2_backends.OAuthLibCore',
    'SCOPES': {"read": "Reading scope", "write": "Writing scope"},
    'DEFAULT_SCOPES': ['__all__'],
    'READ_SCOPE': 'read',
    'WRITE_SCOPE': 'write',
    'AUTHORIZATION_CODE_EXPIRE_SECONDS': 60,
    'ACCESS_TOKEN_EXPIRE_SECONDS': 36000,
    'REFRESH_TOKEN_EXPIRE_SECONDS': None,
    'ROTATE_REFRESH_TOKEN': True,
    'APPLICATION_MODEL': getattr(settings, 'OAUTH2_PROVIDER_APPLICATION_MODEL', 'oauth2_provider.Application'),
    'REQUEST_APPROVAL_PROMPT': 'force',
    'ALLOWED_REDIRECT_URI_SCHEMES': ['http', 'https'],

    # Special settings that will be evaluated at runtime
    '_SCOPES': [],
    '_DEFAULT_SCOPES': [],
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM