Search code examples
google-cloud-platformgmail-api

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.


Solution

  • 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.