[英]Accessing user message list with Gmail API
So i am trying to make this get request to the GMAIL message endpoint: 所以我试图向GMAIL消息端点发出此get请求:
https://www.googleapis.com/gmail/v1/users/test%40email.com/messages?q=from%3Asender%40test.com+is%3Aread&key=MYKEYHERE
But I keep getting a 401 error about login. 但是我一直收到有关登录的401错误。
"code": 401,
"message": "Login Required"
I already authenticated the user with: var SCOPES = ['https://mail.google.com/'];
我已经通过以下方式验证了用户身份: var SCOPES = ['https://mail.google.com/'];
I know this is an Auth issue but dont know how to solve it. 我知道这是Auth问题,但不知道如何解决。 Am I suppose to autheticate the user ever time I need to use the api? 我是否想在每次需要使用api时对用户进行身份验证? What do I do? 我该怎么办?
How can I make this get request from the app that is authroized? 我该如何从经过身份验证的应用程序获取请求?
I have it working in the google testing tool here 我在这里使用谷歌测试工具
*new to oauth2 and appreciate your help. * oauth2的新手,感谢您的帮助。 thanks 谢谢
once you have an access token back from your oauth2 login. 从oauth2登录名返回访问令牌后。 you need to use access_token not key. 您需要使用access_token不是密钥。 Key is use for accessing public APIs. 关键是用于访问公共API。
https://www.googleapis.com/gmail/v1/users/test%40email.com/messages?q=from%3Asender%40test.com+is%3Aread&access_token=YourAccessTokenHere
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.