Package: django-graphql-accounts
django-graphql-accountsdjango-graphql-accountsis a Django/Python application that provides a GraphQL interface for user signup and authentication.  Email addresses are used for authentication, rather than usernames.  Because the authentication user model is based on Django'sAbstractBaseUserand is itself abstract, the model can be extended without the need for additional database tables.  JWT authentication allows the API to be accessed from a variety of front ends, including Django, React and AngularJS clients, and iOS and Android mobile apps.FeaturesAPI endpoints for signup, signup email verification, login, logout, password reset, password reset verification, password change, email change, and user detail.Extensible abstract user model.Perform password confirmation and other client-side validation on the front end for a better user experience.JWT authentication.Useing celery for send registrations email (optional).Useing redis for save registrations token (optional).Installationdjango-graphql-accountsis available on the Python Package Index (PyPI) athttps://pypi.org/project/django-graphql-accounts/.Installdjango-graphql-accountsusing one of the following techniques.Use pip.  Note that particular versions of Django and the Django graphone may be installed.pip install django-graphql-accountsDownload the .tar.gz file from PyPI and install it yourself.Download thesource from Githuband install it yourself.If you install it yourself, also installDjango, theDjango Graphone, andDjango Graphql JWT, andRedis PythonUsageCreate a Django project, if you haven't already. For example,django-adminstartprojectmysiteIn thesettings.pyfile of your project, includedjango_graphql_accountsand `` inINSTALLED_APPS. Set the authentication scheme for the Django Graphql JWT.mysite/settings.py----INSTALLED_APPS=[...'django_graphql_accounts',...]GRAPHENE={"SCHEMA":"config.schema.schema",'MIDDLEWARE':['graphql_jwt.middleware.JSONWebTokenMiddleware',],}AUTHENTICATION_BACKENDS=['graphql_jwt.backends.JSONWebTokenBackend','django.contrib.auth.backends.ModelBackend',]In theschemas.pyfile of your project, Add queries and mutations to the class of your schemas. For example,mysite/schemas.py----importgraphenefromgraphql_jwtimportmutationsfromdjango_graphql_accounts.mutationsimportAccountsMutationfromdjango_graphql_accounts.queriesimportAccountsQueryclassQuery(AccountsQuery,...,graphene.ObjectType):passclassMutation(AccountsMutation,...,graphene.ObjectType):passschema=graphene.Schema(query=Query,mutation=Mutation)Create a Django application for your user data.  For example,pythonmanage.pystartappaccountsIn themodels.pyfile of your application, extendEmailAbstractUser, add custom fields, and assignobjectstoEmailUserManager().  For example,accounts/models.py----fromdjango.dbimportmodelsfromdjango_graphql_accounts.modelsimportEmailUserManager,EmailAbstractUserclassMyUser(EmailAbstractUser):# Custom fieldsdate_of_birth=models.DateField('Date of birth',null=True,blank=True)# ........, etc# Requiredobjects=EmailUserManager()In thesettings.pyfile of your project, SetAUTH_USER_MODELto the class of your user model.  For example,mysite/settings.py----INSTALLED_APPS=[...'django_graphql_accounts','accounts',...]AUTH_USER_MODEL='accounts.MyUser'In theadmin.pyfile of your project, extendEmailUserAdminto add your custom fields.  For example,accounts/admin.py----fromdjango.contribimportadminfromdjango.contrib.authimportget_user_modelUser=get_user_model()@admin.register(User)classUserAdmin(admin.ModelAdmin):passCreate the database tables with Django'smakemigrations,migrate, and create a superuser withcreatesuperuser.pythonmanage.pymakemigrationspythonmanage.pymigratepythonmanage.pycreatesuperuserCheck your setup by starting a Web server on your local machine:pythonmanage.pyrunserverWhen users signup or reset their password, they will be sent an email with a link and verification code.  Include email settings as environment variables or in your project'ssettings.pyfile.  For example,mysite/settings.py----# Email settings# https://docs.djangoproject.com/en/3.1/topics/email/# https://docs.djangoproject.com/en/3.1/ref/settings/#email-hostimportosEMAIL_BACKEND=config('EMAIL_BACKEND')MAILER_EMAIL_BACKEND=config('MAILER_EMAIL_BACKEND')EMAIL_HOST=config('EMAIL_HOST')EMAIL_HOST_PASSWORD=config('EMAIL_HOST_PASSWORD')EMAIL_HOST_USER=config('EMAIL_HOST_USER')EMAIL_PORT=config('EMAIL_PORT')EMAIL_USE_SSL=config('EMAIL_USE_SSL')DEFAULT_FROM_EMAIL=config('DEFAULT_FROM_EMAIL')EMAIL_FROM=os.environ.get('AUTHEMAIL_DEFAULT_EMAIL_FROM')or'<YOUR DEFAULT_EMAIL_FROM HERE>'EMAIL_BCC=os.environ.get('AUTHEMAIL_DEFAULT_EMAIL_BCC')or'<YOUR DEFAULT_EMAIL_BCC HERE>'EMAIL_HOST=os.environ.get('AUTHEMAIL_EMAIL_HOST')or'smtp.gmail.com'EMAIL_PORT=os.environ.get('AUTHEMAIL_EMAIL_PORT')or587EMAIL_HOST_USER=os.environ.get('AUTHEMAIL_EMAIL_HOST_USER')or'<YOUR EMAIL_HOST_USER HERE>'EMAIL_HOST_PASSWORD=os.environ.get('AUTHEMAIL_EMAIL_HOST_PASSWORD')or'<YOUR EMAIL_HOST_PASSWORD HERE>'EMAIL_USE_TLS=TrueEMAIL_USE_SSL=False