【问题标题】:Gmail search with API and access token使用 API 和访问令牌进行 Gmail 搜索
【发布时间】:2018-02-06 13:51:02
【问题描述】:

我正在尝试使用访问令牌从 Gmail API 获取 Gmail 搜索结果。

以下代码有效并返回我的电子邮件 ID 数组:

fetch(`https://www.googleapis.com/gmail/v1/users/${userId}/messages?access_token=${accessToken}`)

然后我尝试在Gmail API documentation guidelines 之后附加一个搜索查询

fetch(`https://www.googleapis.com/gmail/v1/users/${userId}/messages?access_token=${accessToken}?q=${text}`)

它带来了这个错误code: 401, message: 'Invalid Credentials'

身份验证范围设置为https://mail.google.com/,它假定完全控制电子邮件。我尝试交换 access_tokenq 参数,以及删除 access_token 参数但仍然没有成功。我做错了什么?

【问题讨论】:

    标签: http google-api gmail gmail-api


    【解决方案1】:

    `https://www.googleapis.com/gmail/v1/users/${userId}/messages?access_token=${accessToken}?q=${text}

    您正在此调用中执行 HTTP GET。附加参数使用& 附加,只有第一个以? 开头

    试试这个:

    `https://www.googleapis.com/gmail/v1/users/${userId}/messages?access_token=${accessToken}&q=${text}

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-01-31
      • 1970-01-01
      • 2015-09-05
      • 2016-05-20
      • 2016-07-12
      • 1970-01-01
      • 2021-02-05
      • 2016-11-29
      相关资源
      最近更新 更多