【问题标题】:Unexpected response code 403 for https://www.googleapis.com/games/v1/players/1123xxxxxx11712506520 and other play-services errorshttps://www.googleapis.com/games/v1/players/1123xxxxxx11712506520 和其他播放服务错误的意外响应代码 403
【发布时间】:2013-05-17 06:49:16
【问题描述】:

我正在尝试使游戏 API 工作,参考 https://github.com/playgameservices/android-samples/blob/master/BaseGameUtils/src/com/google/example/games/basegameutils/BaseGameActivity.java 作为示例代码。

我的很相似,基本上我正在尝试连接游戏客户端并收到否定答案。当尝试使用 startResolutionForResult() 管理它时,我得到了:

  E/Volley(15638): [1492] il.a: Unexpected response code 403 for https://www.googleapis.com/games/v1/players/112370814111712506xxx
  E/Volley(15638): [1492] il.a: Unexpected response code 403 for https://www.googleapis.com/games/v1/players/112370814111712506xxx
  E/SignInIntentService(15638): Access Not Configured
  [...]
   E/LoadSelfFragment(15748): Unable to sign in - application does not have a registered client ID

最后一条消息“应用程序没有注册的客户端 ID”让我想到 this 问题...但我认为我的问题与应用程序 ID/客户端 ID 无关,因为我正在使用它另一台机器上的相同 API 密钥。我也很确定 SHA1 的正确性,源自当前机器的 debug.keystore。

问题似乎与我正在使用的测试地址有关,奇怪的是我收到的回复并不总是相同:使用相同的键和设置,我有时会得到:

 E/SignInIntentService(15638): Access Not Configured

甚至:

  E/SignInIntentService(15638): Unable to load player

我在 OnConnectionFailedListener 中使用 startResolutionForResult(),它会短暂显示登录屏幕,但随后会因报告错误而崩溃。

  • 另外一个奇怪的是onActivityResult()被调用了,结果码是10004

  • 最后一件事我无法理解的是,为什么在登录失败后,方法 onConnectionFailed() 会被一遍又一遍地调用,从而循环我的应用程序。相关代码为:

    public void initClient() {
            GamesClient.Builder gcBuilder = new GamesClient.Builder(this, cb, cf);
    gcBuilder.setGravityForPopups(Gravity.TOP | Gravity.CENTER_HORIZONTAL);
    //gcBuilder.setScopes(mScopes);
    mGamelient = gcBuilder.create();
    mSchiacciameleView.setGameClient(gcBuilder.create());
    }
    
     OnConnectionFailedListener cf = new OnConnectionFailedListener() {
    public void onConnectionFailed(ConnectionResult arg0) {
        Log.e("Verme", "CONN FAIL:" + arg0.getErrorCode());
        if (arg0.hasResolution()){
            PendingIntent pendingIntent = arg0.getResolution();
            //startResolutionForResult(SchiacciaMeleGame.this, 66);
            try {
                arg0.startResolutionForResult(me, ConnectionResult.SIGN_IN_REQUIRED) ;
            } catch (SendIntentException e) {
                Log.e("Verme", "Err in resolution", e);
            }
        }else{
            Log.e("Verme", "NO RESOLUTION");
        }
    
    }
    

    };

这两天我一直在搞乱这些库。坦率地说,我不喜欢 Google 的管理方式。文档仍然不完整,运行时行为似乎有点不一致(完全相同的代码在另一台机器上运行,SHA1 在两台机器上都是正确的)。也许是我的错?

感谢您的回复

【问题讨论】:

  • 当然可以,我只是想知道是不是我的错。
  • 你如何确定两个 SHA1 都是正确的?

标签: android google-api google-play-services


【解决方案1】:

Step 3. Generate an OAuth 2.0 client ID 中特别给出警告如下:

警告:请勿直接手动打开 Google API 控制台 在该页面上添加您的客户 ID。这样做可能会导致错误 您向游戏服务发送请求。

所以我的经验是你需要虔诚地遵循指南:Setting Up Google Play Game Services with the Google Play Developer Console

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-01-07
    • 1970-01-01
    • 2022-05-20
    • 2021-05-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多