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: docs/technologies/flask/oauth-google.mdx
+16-2Lines changed: 16 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -116,7 +116,6 @@ Some changes will be made to the project files to add an authentication mechanis
116
116
│ └── templates
117
117
├── package.json
118
118
├── README.md
119
-
├── render.yaml
120
119
├── requirements.txt
121
120
└── run.py
122
121
```
@@ -245,15 +244,30 @@ Now requests to `login/google` route will be handled by this route. From your te
245
244
```
246
245
From your browser visit [`127.0.0.1:5000/login/google`](http://127.0.0.1:5000/login/google). Once you have logged in, you will be able to access protected resources in your Flask app.
247
246
247
+
## Adding Signin button to login page
248
+
We will be adding a link to the login page to simplify the signin process for the user.
249
+
250
+
- Add the following code to `apps/templates/accounts/login.html` on line 37
251
+
```html
252
+
<!--apps/templates/accounts/login.html-->
253
+
...
254
+
<divclass="card-body">
255
+
<ahref='login/google'class='btn btn-primary'>Sign in with Google</a>
256
+
...
257
+
```
258
+
This adds a link that points to the authorization route. With this, users can signin to the web application using google authentication wihtout having to change the URL from the browser, making for a better user experience.
259
+
248
260
## Conclusion
249
261
In conclusion, this article has provided an overview of OAuth and its importance in modern web applications. We explored the process of creating a Google OAuth Client ID, which is essential for enabling user authentication and authorization using Google accounts. Additionally, we discussed the steps involved in setting up a Flask application, a popular Python web framework, to handle OAuth authentication.
250
262
251
263
To facilitate OAuth functionality in our Flask application, we installed and configured Flask-Dance, a Flask extension that simplifies the integration of OAuth providers. Specifically, we focused on configuring Flask-Dance with Google OAuth, allowing users to authenticate with their Google accounts in our application.
252
264
265
+
By adding the "Sign in with Google" button to your login page, you provide users with a convenient and secure method to access your Flask application using their Google accounts. This not only simplifies the login process but also enhances the user experience and increases user engagement.
266
+
253
267
By following the steps outlined in this article, developers can leverage the power of OAuth and Google OAuth specifically to enable secure user authentication and authorization in their Flask applications. This process not only enhances the user experience but also provides a seamless integration with widely used social media and identity platforms.
0 commit comments