I have set up the OAuth 2.0
authentication in a Django Rest Framework project with the django_oauth_toolkit
library. But I have noticed the access_token
length is quite short. How can I make these tokens larger? I mean, increase the number of characters each token has.
I have been searching for a setting to do this, but I haven't found anything. I have read all the available settings in the OAUTH2_PROVIDER
settings documentation but found nothing.
I finally fixed it by copying the method to create tokens from Github
changing the parameter length
in a separate file and in settings.py
:
OAUTH2_PROVIDER = {
# this is the list of available scopes
'SCOPES': {'read': 'Read scope',
'write': 'Write scope',
'groups': 'Access to your groups',
'custom': 'Scope de prueba',
'introspection': 'Permiso para ver información de usuario de un token'},
'ACCESS_TOKEN_EXPIRE_SECONDS': 604800,
'ACCESS_TOKEN_GENERATOR': 'api.custom_oauth2_token_generator.custom_generate_token'
}