Confirming emails on your Django/GraphQL API using SendGrid
This repository contains an authentication system, albeit rudimentary that executes email dissemination upon registration. Email to confirm ownership of emails used for registration.
For the web application to run locally a few requirements are necessary:
- Python 3 or newer
- Django
- Graphene Django
- Pipenv
- All the listed dependencies in the requirements.txt file
- Git
NB: All the commands in the README.md on setup and running assume a unix based environment
-
Run the following command from your git command line tool
git clone https://github.com/learningdollars/mainakamau-auth-django-graphql-sendgrid.git
The command clones a local copy of the project folder to your local machine
-
Navigate into the folder that has been created and create a virtual environment and activate the virtual environment by running:
pipenv shell
- Run the migrations command to setup the database tables after installing the requirements in the requirements.txt
python manage.py makemigrations
(this command should create a migrations folder)python manage.py migrate
-
Run the
python manage.py runserver
command to start the application(it should ideally be served on your local address(127.0.0.1:8000
) on port 8000) -
You should get this response on running the application
Performing system checks... System check identified no issues (0 silenced). March 19, 2019 - 06:52:52 Django version 2.1.7, using settings 'django_rest_api.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CONTROL-C.
-
The single endpoint generated by GraphQL ->
http://127.0.0.1:8000/sendgriddemo/
-
Use below mutation after navigating to
http://127.0.0.1:8000/sendgriddemo/
to register a new user with a valid email address
mutation {
createUser(username:"{username}" email: "{email}", password: "{password}"){
user {
email
}
message
}
}
- Check you email and click on the verify button to verify the email.
- Proceed to execute below mutation for successful login
mutation {
loginUser(email: "{email}", password: "{password}"){
message
token
}
}
- To run available tests use:
python manage.py test