When I develop a Python application, sometimes I need to access my Gmail account from the Python source code. But this is not allowed by google by default, you need to configure some settings to make it happen. This article will tell you how to make your Gmail account accessed by less secure apps such as from Python source code.
1. Turn On Allow Less Secure Apps Access Google Account Steps.
- Go to https://accounts.google.com/ web page to log in to your google account.
- Click the Security menu item on left, then scroll down on right and click the Turn on access(not recommended) link under the Less secure app access section in right.
- Now turn on Allow less secure apps:ON toggle button on the new page.
- Now click the back arrow in the title, you can find the Allow less secure apps has been turned on. You can access your Gmail account in your Python code now.
- But as google said this action is not recommended, because there will be risks for your Gmail account. So you had better turn it off after your testing to make your google account more safety.
2. How To Fix Can Not Find The Allow Less Secure Apps Option.
- If you can not find the Less secure app access section on the Security page right side, this is because your Gmail account has enabled the 2-step verification.
- To fix this error, you can either disable the 2-step verification or you can create an app special password for your application, then your less secure apps can access the Gmail account.
- First, you should log in to your Google account, then click the Security link on the page left side.
- Then on the page right side
Signing in to Google
section, click theApp passwords
arrow. - It will open the
App passwords
page. SelectMail
in the Select app drop-down list. Select the device from the Select device drop-down list. - You can also select
Other (Custom name)
from the drop-down list to create your own app password. - Click the Generate button to create the app password.
- Now it will popup a Generated app password dialog to let you see the app password and how to use it in your device and application.
3. How Can I Enable ‘Allow Less Secure Apps’ In Google Apps Script.
3.1 Question.
- I use Google G Suite to develop google apps.
- I want to enable the “Allow less secure apps” option by different domain users in my google apps script.
- I can not find this option in the G Suite Admin SDK. How can I do it?
3.2 Answer1.
- You can not enable this Allow less secure apps option in your source code programmatically.
- You can find this in the Google FAQ.
- And there is a workaround you can take as below.
- Log in to admin.google.com, then click the Security —> Basic settings.
- Then Go to the less secure application settings and check the allow less secure apps option.
“How To Fix Can Not Find The Allow Less Secure Apps Option.” in Latest Update this option is not available
Option to enable or turn on less secure apps is disabled. Could you please help to fix the issue. Even I haven’t enable the 2 step verification.
I write a mail sender to use Gmail account to send test emails for testing. But when I run the application, it shows the error message
Invalid login: Username and Password not accepted. Learn more at https://support.google.com/mail/?p=BadCredentials
I follow this article steps, but I can not find the link that can turn “Less secure apps” on in my Gmail account settings. Can anybody tell me how to fix it? Thanks.
This is because you had enabled the 2-step verification for your Gmail account, you can disable it or use the app special password to fix it. Please read section 2 of this article.
I write a Django application and send emails through the Gmail SMTP server (stmp.gmail.com) in this Django application. When I run my Django app, it popups this error, and I follow this article to fix the error. My question is why google treat my Django app as less secure app? How can I make google to think my Django app as secure app?
Google treats all third-party apps as insecure apps, all apps that want to access a google account need an app password at least. You can read section 2 to learn more.
Hi Susan,
I have tried doing the same thing that he explained above but I am not able to find less secure apps option over there. kindly help me in solving this.
you might need to turn off 2 step verification temporarily.
This is because you have enabled the 2-step verification, please read article section 2 to learn more.
I really thank you .My problem solved