django - allauth and rest-auth facebook login toke

2019-06-11 07:46发布

问题:

I've followed the both packages documentations and using example from rest-auth doc. I've followed all the steps and I can successfully use this API to register/login user with facebook. API returns me token and user object but this token is not working with JWT authentication. But if I set this user's username in the db and then post the facebook login request again then returned token works fine. What does this social authentication process has to do with username? Is there something I need to do to properly configure it?

I am using custom user model and have both username and email for authenticating users. Please let me know if any further info is needed for figuring out the problem.

回答1:

after 1.7.0 in rest_framework_jwt,it use username to query user in authenticate_credentials().But when you use facebook accessToken to login firstly by rest_auth, the user doesn't have a username. So you will recieve a 'Invalid payload.' message. I have this problem too.And I do this work now. Sorry for my bad English skill.