【问题标题】:The issue with OAuth2 of using Google Calendar API in Android app在 Android 应用程序中使用 Google Calendar API 的 OAuth2 问题
【发布时间】:2015-09-10 20:40:16
【问题描述】:

我已尝试根据此链接逐步实现 Google Calendar API:https://developers.google.com/google-apps/calendar/quickstart/android

我在我的 Google Developer Console 中启用了 OAuth2 和 Calendar API。

但由于某些原因,当我想检索日历事件时,我从 Android Studio Logcat 看到以下日志:

出现以下错误: 403禁止

"code" : 403, 
"errors": [
{
     "domain":"usageLimits",
     "message":"Access Not Configured. The API (Calendar API) is not enabled for your project. Please use the Google Developer Console to update your configuration", 
     "reason":"accessNotConfigured",
     "extendedHelp":"https://console.developers.google.com"
}
],
"message":"Access Not Configured. The API (Calendar API) is not enabled for your project. Please use the Google Developer Console to update your configuration"

你能帮我解决这个问题吗?

【问题讨论】:

    标签: android api calendar


    【解决方案1】:

    如错误消息所述:您必须使用 Google Developer Console 启用日历 API。考虑https://developers.google.com/google-apps/calendar/auth 以进一步阅读此主题。

    使用 OAuth 2.0 授权请求

    对 Google Calendar API 的所有请求都必须由 经过身份验证的用户。

    OAuth 2.0 的授权过程或“流程”的详细信息 根据您编写的应用程序类型而有所不同。 以下一般流程适用于所有应用程序类型:

    1. 创建应用程序时,您可以使用 Google Developers Console 进行注册。然后 Google 会提供您需要的信息 稍后,例如客户端 ID 和客户端密码。
    2. 在 Google Developers Console 中激活 Google Calendar API。(如果 API 未在 Developers Console 中列出,则跳过此步骤 步骤。)
    3. 当您的应用程序需要访问用户数据时,它会要求 Google 提供特定的访问范围。
    4. Google 会向用户显示一个同意屏幕,要求他们授权您的应用程序请求他们的一些数据。
    5. 如果用户批准,则 Google 会为您的应用程序提供一个短期访问令牌。
    6. 您的应用程序请求用户数据,并将访问令牌附加到请求中。
    7. 如果 Google 确定您的请求和令牌有效,则会返回请求的数据。

    一些流程包括额外的步骤,例如使用刷新令牌来 获取新的访问令牌。有关流的详细信息 各种类型的应用程序,请参阅 Google 的 OAuth 2.0 文档。

    【讨论】:

      猜你喜欢
      • 2015-09-01
      • 1970-01-01
      • 2013-03-19
      • 2022-09-23
      • 1970-01-01
      • 2011-06-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多