python-social-auth icon indicating copy to clipboard operation
python-social-auth copied to clipboard

Facebook login popup from Angular + JWT + DRF

Open gnud opened this issue 5 years ago • 0 comments

I am having an Angular SPA based frontend and it's server via localhost:4200 (for development), and has proxy for /api at api.mybackend.local. I am using DRF token authentication having Authentication Token bearer. However, the user is always AnonoymousUser since I can't pass the header via a popup window. Also it crashes with state invalid.

Any solution how can I use a popup window to use the social:begin having the Token authentication instead of session? I was researching the season and I found the DjangoStrategy, but don't know if I need to change something there in order to use a token, meanwhile, I made custom authentication that intercepts the token via GET param and logs the users, but I it's not working.

Also, I have a custom subclasses Facebook provider in order to have different permissions, cause I am having one facebook app for one set of users and second app for different set of users.

4 solutions I come up with:

  • iframe in dialog, but I can't capture events like closed or something
  • popup window, automatically closes via the redirect to custom template haveing window.close
  • redirect option, instead of fb to load with popup true in extra data, it can redirect there and pass the token via GET param. But redirect sucks. Any tips are welcomed.

gnud avatar Jul 14 '19 10:07 gnud