expires = datetime.now() + timedelta(seconds=expire_seconds)
access_token = AccessToken.objects.create(user=user, application=
    application, token=random_token_generator(request), expires=expires,
    scope=scopes)
refresh_token = RefreshToken.objects.create(user=user, token=
    random_token_generator(request), access_token=access_token, application
    =application)
token = {'access_token': access_token.token, 'token_type': 'Bearer',
    'expires_in': expire_seconds, 'refresh_token': refresh_token.token,
    'scope': scopes}
return Response(token, status=200)
Как программно сгенерировать токен доступа в Django?