【问题标题】:GoogleAuthorizationRequestUrl builds faulty request URLGoogleAuthorizationRequestUrl 构建错误的请求 URL
【发布时间】:2012-04-05 10:29:03
【问题描述】:

我正在将 Google 日历集成到我的 Android 应用中。用户需要授权才能访问事件信息。我使用 GoogleAuthorizationRequestUrl 来构建授权请求 URL。代码如下(在下面的sn-p中我把原来的client id换成了字符串CLIENT_ID):

String url = new GoogleAuthorizationRequestUrl(CLIENT_ID, 
                    "http://localhost", 
                    "https://www.googleapis.com/auth/calendar.readonly").build();

GoogleAuthorizationRequestUrl 构建的 URL 是:

https://accounts.google.com/o/oauth2/auth?b=https://www.googleapis.com/auth/calendar.readonly&client_id=CLIENT_ID&redirect_uri=http://localhost&response_type=code

而不是

https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/calendar.readonly&client_id=CLIENT_ID&redirect_uri=http://localhost&response_type=code

换句话说,我希望 URL 中有“scope=https://www.googleapis.com/auth/calendar.readonly”,但我有“b=https://www.googleapis.com/auth/ calendar.readonly”。

奇怪的是,我只有在准备发布 APK 时才会收到错误的请求 URL。在我的调试环境中,GoogleAuthorizationRequestUrl 构建了一个正确的 URL。

有人知道这种行为吗?

谢谢, -阿里

【问题讨论】:

    标签: google-api google-calendar-api google-authentication


    【解决方案1】:

    如果有人会阅读这篇文章寻找解决方案,我通过在 proguard.cfg 中添加以下 2 个条目来运行我的实施:

    -keep class com.google.api.client.** { *; }
    
    -keep class com.google.api.services.calendar.model.** { *; }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-04-14
      • 2020-10-24
      • 1970-01-01
      • 2014-12-11
      • 2017-02-03
      • 2020-02-29
      • 1970-01-01
      相关资源
      最近更新 更多