I'm using a python library to log into Gmail. Pretty simple to get started with.
I'm trying to log into my account via this code.
import gmail
g = gmail.login(username, password)
and I receive this error
gmail.exceptions.AuthenticationError
Because google blocked the sign in attempt.
My question is that, is there a way to better authenticate to gmail so Google doesnt block my requests to sign in? I rather not go through the process of generating an OAuth code only because I have multiple gmail accounts I want to log into and retrieve emails from.
Thanks!
Related
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 ?
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.
All i wanted to run a python script to read email from office365 using graph-api.
Everywhere i can see that examples with browser interaction for getting the accessToken.
i have tried with these steps in https://dzone.com/articles/getting-access-token-for-microsoft-graph-using-oau . Retrieved the Access token successfully. But when try to access https://graph.microsoft.com/v1.0/me/messages with access token ended up with "code":"BadRequest","message":"/me request is only valid with delegated authentication flow.".
Can someone help me with proper guidance or available examples.
I am trying to access a gmail account so I can read emails and save PDFs attached to those emails. I wrote the code and it works fine when I tested it on my personal gmail account (something#gmail.com), but now that I am trying to do it for this new address (reporting#company.com, which is a gmail business account) my code isn’t working to even connect.
I get an error message saying
Error: b’[AUTHENTICATIONFAILED] Invalid Credentials (Failure)’
I know the login email and the password are both correct. I have already downloaded the credentials.json file from the Google API page.
My code is as below:
Mail = imaplib.IMAP4_SSL(“imap.gmail.com”)
Mail.login(“reporting#company.com”,’password’)
If you're still using a password in your code, then you need to get your users to enable Less Secure Apps, or if they're using 2-Step Verification, create an App Password.
However, a better approach would be to use OAuth instead of a password. If you've downloaded the credentials.json file from the Google Developers Console, you already did the first step. :) Google has a guide to use OAuth with IMAP in Python, as well as a code sample (see the TestImapAuthentication method there).
All I had to do was enable 2-step authentication on the google account.
I am trying to download emails using imaplib with Python. I have tested the script using my own email account, but I am having trouble doing it for my corporate gmail (I don't know how the corporate gmail works, but I go to gmail.companyname.com to sign in). When I try running the script with imaplib.IMAP4_SSL("imap.gmail.companyname.com", 993), I get an error gaierror name or service not known. Does anybody know how to connect to a my company gmail with imaplib?
IMAP server is still imap.gmail.com -- try with that?
If you're a domain admin you can use my library with a OAuth2 Service Account. If you're an individual user, you might want to look at my code for the oAuth2WebServerFlow. This should allow you to use OAuth (and not a password) to access GMail's IMAP.
https://github.com/richieforeman/oauth2gmail
I am looking for a way to store all my msn messenger chat log (the xml file) to my gmail account.
Just like the gmail chat logs in the "Chats" folder.
Is there any program or web service provide this feature?
I didn't find any program or web service yet. So I guess I may need to write by myself.
I find out google provide a gmail api at http://code.google.com/apis/gmail/oauth/.
It looks like perfect for upload some generated mails to my gmail account.
However, It looks like I need to generate extra headers such as "Recevied", "Received-SPF".
Do all these mail headers required?
I would like to download some gmail chat logs as file format reference, but the chat logs looks like cannot download by imap or pop3. Is there a way I can read the raw mail data?
Thank you. Best Regards