vladkomudrich / react-django-socialAuth

SAuth - a little web-application which demonstrates implementation of social authentication (Google OAuth2 as an example) with Django Rest Framework and React.
7 stars 0 forks source link

After getting the convert token, how to get user's username, email ? #2

Closed ibrahimyaacob92 closed 3 years ago

ibrahimyaacob92 commented 3 years ago

How to get more data other than access & refresh token after it's being converted by Django ?

vladkomudrich commented 3 years ago

You should place access token in each request to get access to different parts of your API.

ibrahimyaacob92 commented 3 years ago

i understand that, but what if i wanted to get the logged in user's detail using the converted token ? What Django give me at the moment is pretty useless if i couldnt refer back to who is generating the token.. image

again It'd be nice if you have an example

vladkomudrich commented 3 years ago

Create view which return some user data and create endpoint to send authenticated request with your token. For example:

class CurrentUserView(APIView): ....permission_classes = [IsAuthenticated] ....serializer_class = AccountSerializer

def get(self, request):
    return Response(data={"user": request.user})