Why does clear_expired reference a 'refresh_token' field
Closed this issue · 3 comments
barraog commented
In the function clear_expired, there is the line:
access_token_query = models.Q(refresh_token__isnull=True, expires__lt=now)
However, AbstractAccessToken defines source_refresh_token not refresh_token. The field is defined as follows:
source_refresh_token = models.OneToOneField(
# unique=True implied by the OneToOneField
oauth2_settings.REFRESH_TOKEN_MODEL,
on_delete=models.SET_NULL,
blank=True,
null=True,
related_name="refreshed_access_token",
)
So I get "cannot resolve refresh_token into field" when I run this function. Am I doing something wrong?
barraog commented
Ah I see the issue, the related name for the access_token field in my implementation of the AbstractRefreshToken class needs to be "refresh_token".
n2ygk commented
Shouldn't you be subclassing DOT's AbstractAccessToken?
barraog commented
Yes I am, its in my implementation class for AbstractAccessToken that I needed to define the related name for access token as "refresh_token". That fixed the issue.