简体   繁体   中英

How to access GMail APIs using api key or username password?

I am following this instructions. I am wondering is there a way to authenticate the GMail APIs without Oauth, like API key or username/password. Using OAUth involves manual intervention.

The GMail api contains private user data. In order to access private user data you must have their permission to access it.

You can access the Gmail api using Oauth2 to request permission of the user of the account to access their data. If this is a gsuite account then you can set up domain wide delegation to a service account and access it that way.

If its not a gsuite account you can have the user authenticate your application once and then store the refresh token using that to gain a new access token as needed but you will always need the users to authenticate your application at least once to get the refresh token.

Login and password is called client login and was turned off by google in 2015. You can also go directly though the smtp or Imap servers using the users login and pass word.

The link in DalmTo's answer above is now outdated. I am also setting this up for a Google Workspace (formally GSuite) account, and here is the updated link to Domain-wide delegation with a Service Account: https://developers.google.com/workspace/guides/create-credentials#service-account

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM