flavors / django-graphql-social-auth

Python Social Auth support for Graphene Django
https://pypi.python.org/pypi/django-graphql-social-auth
MIT License
109 stars 33 forks source link

How do I get the refreshToken with this library #25

Closed roylanmartinez closed 3 years ago

roylanmartinez commented 3 years ago

I tried to get the refreshToken but I could not.

roylanmartinez commented 3 years ago

I solved it using the following mutation:

class SocialAuth(graphql_social_auth.SocialAuthMutation):
    token = graphene.String()
    refresh_token = graphene.String()

    @classmethod
    def resolve(cls, root, info, social, **kwargs):
        if social.user.refresh_tokens.count() >= 1:
            return cls(token=get_token(social.user), refresh_token=social.user.refresh_tokens.last())
        else:
            return cls(token=get_token(social.user), refresh_token=create_refresh_token(social.user))