Hashnut
Hashnut

Reputation: 377

django-allauth) How to get access token from access code in url?

I'm trying to add social login to my django-rest-framework app, but I'm stuck on this problem and need some help.

I used django-allauth to get code, which is used to get access token.

Login Flow: Request code(GET) -> Response -> Request token(POST) -> Response

API reference here

So, after I log in to social account,(e.g. Facebook)click authorize my app button, I get access code like this :

"GET /accounts/kakao/login/callback/?code=1cH2huI2SuGuZxY4wYHU8hieeIXAhhL_XTpTqdR0g5DV1Zn8smcGzheW4IqakEEzNshfMAo9dVoAAAFqzwxacQ&state=uqTv1puHiHuy HTTP/1.1" 200 487

But I just don't know how to get access token from this url! Should I make new view class inside of my view.py file? should I make a new url for getting access token??

Upvotes: 1

Views: 2720

Answers (1)

Yaser Rahimi
Yaser Rahimi

Reputation: 73

i think we need your view to answer this question but i think this maybe work:

add a view like this to views.py:

def social_login(request):
    token = request.GET["code"]
    """Do Some Thing"""

add this to your url.py:

path('/accounts/kakao/login/callback', views.social_login)

Upvotes: 2

Related Questions