Issue with gmail authentication
We are trying to create a node server to read email. We are getting a 500 error after JWT authentication when we are trying to read list of emails.
Here is the gist
https://gist.github.com/spotlmnop/a35ccfbd5c55d549c32e
In order to read a user's email, you need to do OAuth2 authentication with that user and get them to accept the permissions you request. Here you're authenticating with a JWT which is effectively an API-only google account ([email protected]) lacking many user-facing features such as GMail. Does this make sense?
If you operate within a Google Apps domain you can use Domain-wide delegation of authority and then impersonate the user whose data you need to access.
For personal accounts, you will have to use standard Oauth 2.0 flow.
@Alaneor Thanks a ton. Yep, we ended up going oauth 2.0 flow. @ryanseys I did not get it until you explained me. Thank you for your elaborate explanation.
@spotlmnop can you post a gist sample of gmail oauth2 flow, please
@navaru You can see an example of OAuth2 flow here: https://github.com/google/google-api-nodejs-client/blob/master/examples/oauth2.js