Google Api 未在发布模式下进行身份验证

时间:2021-02-24 08:13:05

标签: android google-api google-signin google-classroom

我使用 Google Classroom Api 创建了一个 Google Classroom 客户端应用程序,因此我将 Google Sign In 集成到我的应用程序中,并在开发者控制台中创建了一个 OAuth 客户端 ID。

在调试模式下一切顺利,但现在构建我的应用程序的发布版本,我收到此错误

{
02-24 09:00:55.924 18087-19172/com.codewithmab.classroomclient W/System.err:   "code" : 401,
02-24 09:00:55.924 18087-19172/com.codewithmab.classroomclient W/System.err:   "message" : "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
02-24 09:00:55.924 18087-19172/com.codewithmab.classroomclient W/System.err:   "errors" : [ {
02-24 09:00:55.924 18087-19172/com.codewithmab.classroomclient W/System.err:     "message" : "Login Required.",
02-24 09:00:55.924 18087-19172/com.codewithmab.classroomclient W/System.err:     "domain" : "global",
02-24 09:00:55.924 18087-19172/com.codewithmab.classroomclient W/System.err:     "reason" : "required",
02-24 09:00:55.924 18087-19172/com.codewithmab.classroomclient W/System.err:     "location" : "Authorization",
02-24 09:00:55.924 18087-19172/com.codewithmab.classroomclient W/System.err:     "locationType" : "header"
02-24 09:00:55.924 18087-19172/com.codewithmab.classroomclient W/System.err:   } ],
02-24 09:00:55.924 18087-19172/com.codewithmab.classroomclient W/System.err:   "status" : "UNAUTHENTICATED"
02-24 09:00:55.924 18087-19172/com.codewithmab.classroomclient W/System.err: }

我将凭据传递为

GoogleAccountCredential credential = GoogleAccountCredential.usingOAuth2(coursesActivity, Arrays.asList(SCOPES));
                    credential.setSelectedAccountName(account.getDisplayName());
                    credential.setSelectedAccount(account.getAccount());


                    Classroom service = new Classroom.Builder(AndroidHttp.newCompatibleTransport(), jsonFactory, credential)
                            .setApplicationName("Classroom")
                            .build();

事实上在调试模式下一切都很好,刚才在发布模式下我得到了这个。

请我为调试和发布模式使用相同的签名密钥

0 个答案:

没有答案