Skip to content

How to use headless api in drf #3823

Closed Answered by pennersr
kagiya-n asked this question in Q&A
Discussion options

You must be logged in to vote

Without knowing any specifics this is difficult to answer, as authentication is pluggable over at DRF. In any case, allauth headless uses session authentication on the browser, and an X-Session-Token header for apps. So, if you configure DRF to use sessions as well, the browser case is covered. As for apps, you can either setup DRF to recognize the X-Session-Token header and use that throughout your app. Or, if you want, you can configure allauth to generate an access token. You would have to hook something like this up:

from rest_framework.authtoken.models import Token

def create_access_token(self, request):
    token = Token.objects.create(user=...)
    return token.key

.. over here:

h…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@kagiya-n
Comment options

Answer selected by kagiya-n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants