我正在使用Google Drive API将google驱动器集成到我的应用中,并且需要使用Google登录API来访问该帐户。我使用the guide by Google从Google API控制台生成了我的userTokenID(我使用了Web客户端OAuth 2.0)。这是我的单曲GSO:
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.requestIdToken(getString(R.string.google_id_client))
.requestScopes(Drive.SCOPE_APPFOLDER)
.requestScopes(Drive.SCOPE_FILE)
.build();
问题在于,当所选择的新帐户注册时,如下图所示:
并且注册结束,屏幕保持灰色,如下所示:
Screen stays grey after sign in
由于某种原因,永远不会调用和onActivityResult()。点击覆盖屏幕后,所有内容都回到了开始状态,我在代码的这一部分中收到了Google错误代码8:INTERNAL ERROR:
private void handleSignInResult(Task<GoogleSignInAccount> completedTask) {
try {
// Signed in successfully, show authenticated UI.
if (completedTask.getResult(ApiException.class) != null) {
mPresenter.firstPreparations();
selectedItems = new ArrayList<>();
changeVisibility(true);
}
} catch (ApiException e) {
// The ApiException status code indicates the detailed failure reason.
// Please refer to the GoogleSignInStatusCodes class reference for more information.
Log.e(TAG, e.getStatusCode()+"");
changeVisibility(false);
}
}
登录仅在手机上注册帐户时有效。
我尝试过: