Skip to main content

Graphql Social authentication system with Strawberry for Django.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

strawberry_django_social_auth-0.4.4.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

strawberry_django_social_auth-0.4.4-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file strawberry_django_social_auth-0.4.4.tar.gz.

File metadata

  • Download URL: strawberry_django_social_auth-0.4.4.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.14.6 Linux/6.17.0-1018-azure

File hashes

Hashes for strawberry_django_social_auth-0.4.4.tar.gz
Algorithm Hash digest
SHA256 b3bd72ea3f08562dfa6504691a6f507cec3e0bbb186fdc57b92a9c5fa49f1b80
MD5 57455c44515129c3217af32762b35e5d
BLAKE2b-256 763370733b09eaf93ce796125d25f57327f2dfd23e6cfbfe0bfd10ec61b876e8

See more details on using hashes here.

File details

Details for the file strawberry_django_social_auth-0.4.4-py3-none-any.whl.

File metadata

File hashes

Hashes for strawberry_django_social_auth-0.4.4-py3-none-any.whl
Algorithm Hash digest
SHA256 6eb0502ffd9c6ee14aa2819ef980a58dc3f04de3b3bae1a8e39ea100d159988b
MD5 7b618318f48fde685c6a62609d28ef0c
BLAKE2b-256 fcc5fe2dd62fd7faee36a330618c8864fe94a4eeb52d1327e6dc5e46bd759a73

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page