RealmTeam / django-rest-framework-social-oauth2

python-social-auth and oauth2 support for django-rest-framework
MIT License
1.06k stars 191 forks source link

OpenID Issues #117

Closed tgmendes closed 7 years ago

tgmendes commented 7 years ago

Good afternoon,

I am using DRF-social-oauth2 to login using openid connect.

Currently I am trying to login to the yahoo openid provider (https://me.yahoo.com).

Everything works well but I am not able to figure out how to move on after the login. Where do I get the token to make requests to the API?

Steps are:

  1. User attempts to login (http://127.0.0.1:8000/auth/login/yahoo)
  2. User is redirected to the Yahoo openid page, where he logs in
  3. After successful login, user is sent back to the login redirect url (in my case, back to 127.0.0.1).

However, I would like to do more. I am trying to integrate the Django backend with an Angular app, and I need to somehow have a token to authenticate through the API, but I don't see how that token can be obtained.

I appreciate any help or tutorials, since I don't seem to find any solution to my problem.

Kind regards, Tiago

PhilipGarnero commented 7 years ago

It seems to me that you're going on the wrong route. My package is dedicated to apis but auth/login/yahoo is for python-social-auth to login using django templates. What you actually need to do is to get the openid token from yahoo client side (using javascript if in browser) and send that token over to my library so it can convert it to a in house token.

tgmendes commented 7 years ago

You are right @PhilipGarnero

I did the approach you mentioned and everything worked perfectly!

Defined an openid backend with information on client id and secret, got the token for that backend from the javascript code and requested to convert the token to a Django token. After that, requests to the API using that token worked like a charm!

Thanks!