You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: twilio_sendgrid/04_email_verification.md
+18-18Lines changed: 18 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
-
# Email Verification Using SendGrid, Verify and Flask
1
+
# Email Verification Using SendGrid, Verify, and Flask
2
2
3
-
When you search how to send emails in flask, you will come across a ton of content on how to do so. Below, you will learn how to utilize Twilio SendGrid to send emails from a flask application.
3
+
When you search for how to send emails in Flask, you will come across a ton of content on how to do so. Below, you will learn how to utilize Twilio SendGrid to send emails from a flask application.
4
4
5
-
One possible use case of sending emails is when you want to enforce the authenticity of user emails in your application. A user who keys in their email address will be required to prove that they have access to the email by retrieving a token sent to their inbox.
5
+
One possible use case for sending emails is when you want to enforce the authenticity of user emails in your application. A user who keys in their email address will be required to prove that they have access to the email by retrieving a token sent to their inbox.
6
6
7
7
### Table of Contents
8
8
@@ -16,7 +16,7 @@ If you would like to browse the completed project, you can check out the [Email
16
16
17
17
## Working With SendGrid
18
18
19
-
At this point you should have a SendGrid account. If not, review [how to create a free account](/twilio_sendgrid/01_create_acccount.md) now. The first step would be to come up with a template for our email. Twilio Verify Service will use this template when emailing verification codes to users.
19
+
At this point, you should have a SendGrid account. If not, review [how to create a free account](/twilio_sendgrid/01_create_acccount.md) now. The first step would be to come up with a template for our email. Twilio Verify Service will use this template when emailing verification codes to users.
20
20
21
21
- From the [SendGrid dashboard](https://app.sendgrid.com/), click on "Email API" located in the sidebar, then select "Dynamic Templates"
@@ -54,16 +54,16 @@ When you click the "Create and View" button, an API key will be created. Make su
54
54
55
55
### Create Email Integration
56
56
57
-
From now, we will move to our Twilio account to complete the configuration and link it to SendGrid. From the [Twilio Console](https://console.twilio.com/), click on "Verify" Service to access [Email Integration](https://console.twilio.com/us1/develop/verify/settings/email) found in.
57
+
From now, we will move to our Twilio account to complete the configuration and link it to SendGrid. From the [Twilio Console](https://console.twilio.com/), click on "Verify" Service to access [Email Integration](https://console.twilio.com/us1/develop/verify/settings/email) found in.
For the SendGrid API key, you will need to retrieve the earlier copy saved in the `.env` file. The template key is found in your SendGrid Dynamic templates page. Click Save to store the email integration.
61
+
For the SendGrid API key, you will need to retrieve the earlier copy saved in the `.env` file. The template key is found on your SendGrid Dynamic templates page. Click Save to store the email integration.
62
62
63
63
64
64
### Create A Verify Service
65
65
66
-
Explore Twilio's products catalogue to Find "Verify" within the Account Security section. You can pin this to access is easily in future.
66
+
Explore Twilio's products catalog to Find "Verify" within the Account Security section. You can pin this to access it easily in the future.
@@ -87,7 +87,7 @@ I have already created a sample application we can use to build our project. You
87
87
88
88
### Install Twilio
89
89
90
-
Besides the dependancies installed through the _requirements.txt_ file, we will need to also install `twilio` within our active virtual environment. Run this command below:
90
+
Besides the dependencies installed through the _requirements.txt_ file, we will need to also install `twilio` within our active virtual environment. Run this command below:
91
91
92
92
```python
93
93
(venv)$ pip3 install twilio
@@ -126,12 +126,12 @@ class EmailForm(FlaskForm):
126
126
127
127
```
128
128
129
-
We have used the class `EmailForm()` to define what fields we want, in this case it is only the `email` field together with a `submit` button.
129
+
We have used the class `EmailForm()` to define what fields we want, in this case, it is only the `email` field together with a `submit` button.
130
130
131
131
132
132
### Web Form Configuration
133
133
134
-
To help protect our form from a nasty attack called CrossSite Request Forgery (Csrf in short), Flask expects us to initialize a `SECRET_KEY` configuration. We can do so by creating a `config` module in the top-level directory.
134
+
To help protect our form from a nasty attack called Cross-Site Request Forgery (Csrf in short), Flask expects us to initialize a `SECRET_KEY` configuration. We can do so by creating a `config` module in the top-level directory.
135
135
136
136
```python
137
137
(venv)$ touch config.py
@@ -155,7 +155,7 @@ class Config(object):
155
155
156
156
```
157
157
158
-
The value is located in another top-level file called `.env` which should not be commited to version control. Its content should remain a secret. Ensure you add it to a `.gitignore` file.
158
+
The value is located in another top-level file called `.env` which should not be committed to version control. Its content should remain a secret. Ensure you add it to a `.gitignore` file.
159
159
160
160
```python
161
161
#.env
@@ -218,7 +218,7 @@ The dynamic data `{{ title }}` comes from the title passed when the template is
218
218
219
219
### Render The Email Form
220
220
221
-
The routes module is used to combine all logic related to view functions. We will need to update in order for our form to be displayed.
221
+
The routes module is used to combine all logic related to view functions. We will need to update it for our form to be displayed.
222
222
223
223
```python
224
224
# app/routes.py
@@ -236,7 +236,7 @@ def index():
236
236
237
237
```
238
238
239
-
We begin by importing our `EmailForm` from the forms module, then instantiate it using the variable `form`. It is this variable that is passed,the template, that is used to render our form. If your application is still running, you can refresh the home/index page to see the email form.
239
+
We begin by importing our `EmailForm` from the forms module, then instantiate it using the variable `form`. It is this variable that is passed,the template, that is used to render our form. If your application is still running, you can refresh the home/index page to see the email form.
To use the Verify API, we first need to get our service's client. This is done handled by our helper method `_get_twilio_verify_client()`. You will need your Twilio account's SID and Auth token seen in your [console](https://console.twilio.com/). You will also need the Verify Service SID as discussed in the section [Create a Verify Service](#create-a-verify-service).
290
+
To use the Verify API, we first need to get our service's client. This is handled by our helper method `_get_twilio_verify_client()`. You will need your Twilio account's SID and Auth token seen in your [console](https://console.twilio.com/). You will also need the Verify Service SID as discussed in the section [Create a Verify Service](#create-a-verify-service).
291
291
292
-
Notice that they are all environment variables. So, we need to update our configurations file.
292
+
Notice that they are all environment variables. So, we need to update our configuration file.
293
293
294
294
```python
295
295
# config.py
@@ -318,7 +318,7 @@ TWILIO_VERIFY_SERVICE_ID=
318
318
SENDGRID_API_KEY=
319
319
```
320
320
321
-
The `request_email_verification_token()` method contacts Twilio Verify to request for a verification token. A user's email is passed as an argument so that the email can be sent to their inbox.
321
+
The `request_email_verification_token()` method contacts Twilio Verify to request a verification token. A user's email is passed as an argument so that the email can be sent to their inbox.
322
322
323
323
The request process is handled by the `index()` view function as seen below:
324
324
@@ -363,9 +363,9 @@ def verify_token():
363
363
364
364
```
365
365
366
-
In the token verification page, there will be another simple form with only one field that accepts the numeric code received by a client. Once this form is submited with the code, a call to the method `check_email_verification_token()` is made. If the token is verified, then the user will be redirected to the index page.
366
+
On the token verification page, there will be another simple form with only one field that accepts the numeric code received by a client. Once this form is submitted with the code, a call to the method `check_email_verification_token()` is made. If the token is verified, then the user will be redirected to the index page.
367
367
368
-
Let us begin by creating this new template. We can copy the content of the `index.html` and paste into `verify.html`.
368
+
Let us begin by creating this new template. We can copy the content of the `index.html` and paste it into `verify.html`.
0 commit comments