使用Gmail SDK [Python]在第三方应用中实现2FA

发布于 2025-02-09 08:33:39 字数 284 浏览 3 评论 0原文

我的要求如下: 在我的Web应用程序中,用户注册了他们的电子邮件ID。我对此有一个基本的正则验证,但是我也想检查他们的邮件ID是否有效而无需发送邮件。

验证应该是使用户单击Web应用中的验证 - email-id时,它应重定向到Gmail中的2FA,用户应在此处获得2位数字,并且Web应用程序还应接收它,然后用户应输入用户编号,然后如果匹配,则将其添加到已验证的MailIDS中。

我一直在寻找这一点,但是还没有在网上找到很多帮助。是否可以实现此方法,或者是否有其他方法可以在编程中使用Gmail API验证电子邮件ID?

My requirement is as follows:
In my web application, users register their emailIds. I have a basic regex validation handled for that, but i also want to check if their mailIds are valid without sending a mail.

Verification should be such that when user clicks on verify-email-id in the web app, it should redirect to 2FA in gmail where the user should get a 2 digit number and the web app should also receive it, the user should then enter the number and then if it matches, add that to validated mailIds.

I have been looking up about this, but havent found much help online. Can this approach be implemented or is there any other way to programatically validate emailIds using Gmail API ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

铃予 2025-02-16 08:33:39

要验证电子邮件,您应该将电子邮件发送到帐户,并让他们单击验证电子邮件响应。

验证应使得用户单击Web应用中的验证 - email-id时,它应重定向到gmail中的2FA,用户应获得2位数字,并且Web应用程序也应接收到它,用户应然后输入数字,然后如果匹配,则将其添加到已验证的MailID。

这不是验证正在验证Google帐户退出的电子邮件。通过要求用户登录到他们的帐户。您要做的是不工作。登录和授权流在Googles授权服务器上处理。这不是您要看到的。 Google将返回您的ID_Token,并向您展示用户是谁。仅此而已。

如果要在系统中启用2FA,则必须在自己的授权服务器上进行操作。

使用gmail api

编程验证电子邮件

这是Gmail API的范围。要访问Gmail API,您将不得不请求对用户的授权,只是要看到他们有有效的电子邮件,这已经过时了。甚至读取的Gmail范围也受到限制。您的应用程序的验证过程将非常复杂且昂贵,以查看电子邮件是否退出。 Google可能不会批准该应用程序,因为这不是Gmail API的有效用例。

再次,验证电子邮件帐户的最佳方法是发送电子邮件。

To verify an email exists you should send an email to the account and have them click a verify email response.

Verification should be such that when user clicks on verify-email-id in the web app, it should redirect to 2FA in gmail where the user should get a 2 digit number and the web app should also receive it, the user should then enter the number and then if it matches, add that to validated mailIds.

That's not verifying an email that's verifying a google account exits. By asking the user to login to their account. What you want to do is not going to work. The login and authorization flow is handled on googles authorization server. This isn't something your going to see. Google will return to you an Id_token with claims to show you who the user is. That is all.

If you want to enable 2fa in your system your going to have to do it on your own authorization server.

programatically validate emailIds using Gmail API

This is out of scope for the gmail api. To get access to the gmail api your going to have to request authorization of the user, just to see that they have a valid email this is over kill. Even the read only gmail scope is restricted. The verification process for your app is going to be very complicated and expensive just to see if the email exits. Google probably wont approve the app anyway as this is not a valid use case for the gmail api.

Again The best way to verify an email account exists, is to send an email.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文