为什么我知道用于从 gmail API 获取电子邮件的用户 ID 和消息 ID?

Why do I know the user ID and message ID for getting email messages from the gmail API?

我有一个 Angular 6 应用程序。我正在尝试通过连接到 Google 的 API.

从我的 gmail 帐户中检索我的电子邮件

这里 link 解释了如何:

https://developers.google.com/gmail/api/v1/reference/users/messages/get#examples

它说用你的用户 ID 和消息 ID 调用这个端点:

https://www.googleapis.com/gmail/v1/users/userId/messages/id

问题是,我不知道我的用户 ID 或消息 ID 是什么。我该如何解决?

PS - 我没有使用 gapi 客户端库或任何库,因为我正在尝试对应用程序进行编程以能够访问任何 API 端点,而不仅仅是 Google的。

如您链接到的文档中所述...

  /**
   * Get Message with given ID.
   *
   * @param service Authorized Gmail API instance.
   * @param userId User's email address. The special value "me"
   * can be used to indicate the authenticated user.
   * @param messageId ID of Message to retrieve.
   * @return Message Retrieved Message.
   * @throws IOException
   */

userId: User's email address. The special value "me" can be used to indicate the authenticated user.

我想您会通过使用 API 检查单个消息对象来找到消息 ID。如果您不知道任何消息 ID,从逻辑上讲您将无法检查单个消息,您需要获取所有消息然后选择一个。