Closed eakenbor closed 10 months ago
Did you ever resolve this issue? I am looking to conduct a similar thing as you by combining social authentication with knox!
@olaokoroafor, try this:
settings.py
REST_AUTH_SERIALIZERS = {
...
"TOKEN_SERIALIZER": "users.serializers.KnoxSerializer",
...
}
REST_AUTH_TOKEN_MODEL = "knox.models.AuthToken"
REST_AUTH_TOKEN_CREATOR = "users.utils.create_knox_token"
REST_FRAMEWORK = {
...
"DEFAULT_AUTHENTICATION_CLASSES": (
...
"knox.auth.TokenAuthentication",
),
}
utils.py
def create_knox_token(token_model, user, serializer):
instance, token = AuthToken.objects.create(user=user)
return {"expiry": instance.expiry, "user": instance.user, "token": token}
Thank you so much!!! This is very helpful.
Would everything from your previous implementation stay the same?
Yes
I can successfully log in using email and password, but when I try to use social authentication in combination with django allauth and dj rest auth, I get the following error:
Here is my views.py
urls.py
serializers.py
settings.py
Please can someone help me with this?