Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hi, everyone. Can't get JWT Token #57

Open
GrechkinDV opened this issue Jun 12, 2021 · 11 comments
Open

Hi, everyone. Can't get JWT Token #57

GrechkinDV opened this issue Jun 12, 2021 · 11 comments
Labels
drf-oauth2 jwt major version Automatically create a new major version tag after PR is merged

Comments

@GrechkinDV
Copy link

ACTIVATE_JWT is set to True. Though, I still get only Bearer token after convert-token request.

@vipinmohan22
Copy link

ACTIVATE_JWT is set to True. Though, I still get only Bearer token after convert-token request.
Same here. I've been pulling my hair out due to this

@GrechkinDV
Copy link
Author

Social Oauth

ACTIVATE_JWT = True
DRFSO2_URL_NAMESPACE = "drf"

Have you got things like this?

@vipinmohan22
Copy link

yes

@GrechkinDV
Copy link
Author

What's about your urls setup?

@vipinmohan22
Copy link

vipinmohan22 commented Jul 26, 2021

path('auth/', include('drf_social_oauth2.urls', namespace='drf')),

did you manage to get it to work?

@wagnerdelima
Copy link
Owner

Sorry about the delay. Did you manage to get this fixed? Can you paste more information about your problem?

@denizdogan
Copy link
Contributor

I do get a JWT, but I have no idea how to use it in my client.

When I try this:

Authorization: Bearer eyJhbGci...

I get this:

{
    "detail": "Given token not valid for any token type",
    "code": "token_not_valid",
    "messages": [
        {
            "token_class": "AccessToken",
            "token_type": "access",
            "message": "Token has no 'exp' claim"
        }
    ]
}

When I do this:

Authorization: Bearer facebook eyJhbGci...

I get this:

{
    "detail": "Authorization header must contain two space-delimited values",
    "code": "bad_authorization_header"
}

@denizdogan
Copy link
Contributor

Turned out that I had traces of rest_framework_simplejwt all over my code base. Removing these helped solve my issue.

@wagnerdelima
Copy link
Owner

@GrechkinDV this is definitely not an error by drf-social-oauth2. That might be simplejwt as @denizdogan mentioned.

@wagnerdelima wagnerdelima added major version Automatically create a new major version tag after PR is merged drf-oauth2 jwt labels Apr 17, 2023
@codewitgabi
Copy link

So does that mean there's no way to use both rest_framework_simplejwt and drf_social_oauth2

@codewitgabi
Copy link

So I was able to fix my issue and use both rest_framework_simplejwt and drf_social_oauth2.

  • Firstly in the documentation, it is stated that to authenticate an endpoint you should use Authorization: Bearer <backend> <token> Which doesn't work. I think this should be corrected to Authorization: Bearer <token> as this is what works.
  • To use both packages, I did
SIMPLE_JWT = {
   # other settings
    "AUTH_HEADER_TYPES": ("JWT",),
}

So for rest_framework_simplejwt I use Authorization: JWT <token> and for drf_social_oauth2, I use Authorization: Bearer <token>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
drf-oauth2 jwt major version Automatically create a new major version tag after PR is merged
Projects
None yet
Development

No branches or pull requests

5 participants