2016-12-02 52 views

回答

5

設置您的設置:

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

這將設置你的到期時間爲15分鐘。 第二個和第三個常量是可選的,僅用於顯示您可以執行的操作。

您可以覆蓋所有的這些:

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': [], 
} 
+0

感謝@ EmilioK它爲我三江源非常多 –