django-graphql-jwt
django-graphql-jwt copied to clipboard
Obtain web token from within a mutation
I want to login the user (ObtainWebTokenMutation) from within mutation for registration itself. So, the differentiating factor from the usual case is that the username and password won't be there as arguments to a mutation. Instead I'd need to take the functionality from that mutation and put it into a util which will get the token and make required changes, e.g. change the context object, and sending the token_issued event. For now it seems that all the code I require is in the @token_auth decorator which is to be used with a mutation where the username and password are kwargs supplied to it.
Is there like a util for this or any ideas on how I can do it without copy-pasting the token_auth code into my mutation?
hello, have you found any solution for this? I also want to use openid-auth-token for authenticate
This was a long time ago. But if I remember correctly, I just invoked the Login mutation from within the register mutation. Like Login.resolve(username, password) and using an extra login key in the response to contain the token and everything that would normally be returned from the login mutation. This is still a bit hacky, something like a util would still be more preferable