question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

how do i obtain token during signup?

See original GitHub issue

When user signs up then how do i obtain the token for that user so i can login automatically just after successful signup.

Here is my registration code

class Register(graphene.Mutation):
    class Arguments:
        email = graphene.String(required=True)
        password = graphene.String(required=True)
        password_repeat = graphene.String(required=True)

    user = graphene.Field(UserQuery)
    token = graphene.String()
    success = graphene.Boolean()
    errors = graphene.List(graphene.String)

    @staticmethod
    def mutate(self, info, email, password, password_repeat):
        if password == password_repeat:
            try:
                user = User.objects.create(email=email)
                user.set_password(password)
                user.is_active = False
                user.full_clean()
                user.save()
               # i need to pass token as well
                return Register(success=True, user=user)
            except ValidationError as e:
                return Register(success=False, errors=[e])
        return Register(success=False, errors=['password', 'password is not matching'])

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
mongkokcommented, Aug 17, 2019

Hi @SanskarSans ,

from graphql_jwt.shortcuts import create_refresh_token, get_token

token = get_token(user)
refresh_token = create_refresh_token(user)

I close the issue, if you have any questions please let me know.

2reactions
mcabramscommented, Sep 13, 2019

@mongkok how would this be achieved if one has opted for the JWT stored in cookie approach?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Get Access Tokens - Auth0
Learn how to request Access Tokens using the Authorize endpoint when authenticating users and include the target audience and scope of access requested...
Read more >
How to mint and use initial tokens for client registration
Step 2. Obtain the required initial registration token(s) ... Make a call at the direct authorisation endpoint to obtain the actual initial token...
Read more >
How to get an access token with Auth Code Grant | DocuSign
To get a new access token, use the refresh token as you would an authorization code, but with a grant_type value of refresh_token...
Read more >
Get access token during Auth Registration Handler(Auth ...
As far as I know we can get access token by using Auth.AuthToken.getAccessToken, but this user context and Auth.RegistrationHandler runs is ...
Read more >
Using the token model | Authorization - Google Developers
Find or create a client ID by following the steps described in the Get your Google API client ID guide. Next, add the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found