Giter VIP home page Giter VIP logo

strawberry-django-social-auth's Introduction

Tests

Codecov

Pypi

contributions welcome

Pypi downloads

Python versions

Strawberry-django Social Auth

Django social authentication with Strawberry using Social Django.

About

This Library was inspired by Django-graphql-social-auth.

Django Social Auth for Strawberry Graphql engine.

Docs can be found here

Features

  • Awesome docs!
  • Social Auth
  • Profile pic's URL storage in User's model
  • Relay Support (Coming Soon...)

Installation:

pip install strawberry-django-social-auth
  • Add this for Avatar support in settings.py
SOCIAL_AUTH_PIPELINE = [
    ...
    'gql_social_auth.pipeline.get_avatar',  # Get Avatar Pipeline
]

Usage:

  1. Use built-In Mutation
@strawberry.type
class Mutation:
    social_auth = mutations.SocialAuth.field

schema = strawberry.Schema(query=Query, mutation=Mutation)
  1. Customize the Usage of Mutation using the decorator
from gql_social_auth.decorators import social_auth
from gql_social_auth.types import SocialAuthInput

@strawberry.type
class CustomMutation:
    @strawberry.mutation
    @social_auth
    def social_auth(self, info: Info, _input: SocialAuthInput, user, errors) -> CustomReturnType:
        # user: User object from model
        # errors: If any errors occurred during the process of getting the social auth
        # Note: Any of the user or errors is None at a time, both can't be None at the same time...
        if errors is not None:
            # Handle Error here
        # Use user Object here... 
        

Calling:

mutation SocialAuth($provider: String!, $accessToken: String!){
    socialAuth(provider: $provider, accessToken: $accessToken){
        uid
        avatar
        extraData
        errors
        success
        refreshToken {
            created
            isExpired
            expiresAt
            token
            revoked
        }
        token {
            token
            payload {
                exp
                origIat
            }
        }
        user {
            email
            archived
            dateJoined
            firstName
            isActive
            id
            isStaff
            isSuperuser
            lastLogin
            lastName
            logentrySet {
                pk
            }
            status {
                archived
                verified
            }
            verified
        }
      }
    }

Contributing

See CONTRIBUTING.md

strawberry-django-social-auth's People

Contributors

shritesh99 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.