Generating single access token with Django OAuth2 Toolkit

前端 未结 3 976
天命终不由人
天命终不由人 2021-02-05 15:05

I\'m using the latest Django OAuth2 Toolkit (0.10.0) with Python 2.7, Django 1.8 and Django REST framework 3.3

While using the grant_type=password, I notice

3条回答
  •  面向向阳花
    2021-02-05 16:03

    The accepted answer still fails to clear the RefreshToken. Below code should revoke both the refresh and access token.

    from oauth2_provider.models import RefreshToken
    def clear_token(user):
    """
    Clear all user authorized tokens.
    """
    for token in RefreshToken.objects.filter(user=user, revoked__isnull=True):
        token.revoke()
    

提交回复
热议问题