Google фрагмент getSignInIntent () возвращает RESULT_CANCELED - PullRequest
0 голосов
/ 12 марта 2019

В приложении для Android я пытаюсь использовать API входа в Google для входа в учетную запись Google пользователя, чтобы я мог использовать DRIVE API.

GoogleSignInOptions signInOptions =
        new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
        .requestEmail()
        .requestServerAuthCode(client_id, true)
        .requestScopes(new Scope(DriveScopes.DRIVE_FILE))
        .build();

GoogleSignInClient client = GoogleSignIn.getClient(this, signInOptions);


// The result of the sign-in Intent is handled in onActivityResult.
startActivityForResult(client.getSignInIntent(), REQUEST_CODE_SIGN_IN);

Это должно быть подхвачено OnActivityResult.

@Override
public void onActivityResult(int requestCode, int resultCode, Intent resultData) {

switch (requestCode) {
  case REQUEST_CODE_SIGN_IN:
    if (resultCode == Activity.RESULT_OK && resultData != null) {

      handleSignInResult(resultData);
    }
    break;
}

super.onActivityResult(requestCode, resultCode, resultData);
}

Однако, как только фрагмент всплывает и я выбираю учетную запись, код результата 0 (RESULT_CANCELED) всегда возвращается в onActivityResult. Я не знаю, что вызывает это. Я включил часть трассировки стека ниже:

03-12 10:11:14.928  9706 22776 I Authzen : [DeviceStateSyncManager] The server is in sync with current state. Nothing to do
03-12 10:11:16.425 22710 22710 D AccountChip: Account selected: 0
03-12 10:11:16.434  9701 10261 D GoogleCertificatesImpl: isGoogleReleaseSigned: false
03-12 10:11:16.435  9701 10261 D GoogleCertificatesImpl: isGoogleReleaseSigned: false
03-12 10:11:16.491  9701 22333 D SqlitePlayLoggerContextTable: SELECT: id=10228
03-12 10:11:16.492  9701 22333 D SqliteLogEventTable: INSERT: id=213023
03-12 10:11:16.505 22710 22743 D OpenGLRenderer: endAllActiveAnimators on 0x7876491e00 (ListView) with handle 0x78779ff860
03-12 10:11:16.519  9701 22666 D SqlitePlayLoggerContextTable: SELECT: id=10228
03-12 10:11:16.520  9701 22666 D SqliteLogEventTable: INSERT: id=213024
03-12 10:11:16.528  9701 10261 D GoogleCertificatesImpl: isGoogleReleaseSigned: false
03-12 10:11:16.534  9701 10261 I chatty  : uid=10031(com.google.android.gms) Binder:9701_E identical 3 lines
03-12 10:11:16.535  9701 10261 D GoogleCertificatesImpl: isGoogleReleaseSigned: false
03-12 10:11:16.537  9701  9748 D GoogleCertificatesImpl: isGoogleReleaseSigned: false
03-12 10:11:16.541  9701  9748 D GoogleCertificatesImpl: isGoogleReleaseSigned: false
03-12 10:11:16.559   929 18409 D DrmHal  : found drm@1.0 IDrmFactory clearkey
03-12 10:11:16.560   929 18409 D DrmHal  : found drm@1.0 IDrmFactory default
03-12 10:11:16.561   929 18409 D DrmHal  : found drm@1.0 IDrmFactory widevine
03-12 10:11:16.562   929 18409 D DrmHal  : found drm@1.1 IDrmFactory clearkey
03-12 10:11:16.563   929 18409 D DrmHal  : found drm@1.1 IDrmFactory widevine
03-12 10:11:16.563  9701 22333 D SqlitePlayLoggerContextTable: SELECT: id=10230
03-12 10:11:16.564  9701 22333 D SqliteLogEventTable: INSERT: id=213025
03-12 10:11:16.564   767  4666 D WVCdm   : Instantiating CDM.
03-12 10:11:16.566   767  4666 I WVCdm   : [cdm_engine.cpp(480):QueryStatus] CdmEngine::QueryStatus
03-12 10:11:16.567   767 22779 I WVCdm   : [(0):] Level3 Library 4445 Apr 20 2018 14:53:46
03-12 10:11:16.584   767  4666 I WVCdm   : [oemcrypto_adapter_dynamic.cpp(575):Initialize] L3 Initialized. Trying L1.
03-12 10:11:16.585   767  4666 D         : CPPF_ServiceInitialize: start!
03-12 10:11:16.585   767  4666 D QSEECOMAPI: QSEECom_get_handle sb_length = 0x2800
03-12 10:11:16.586   767  4666 D QSEECOMAPI: App is not loaded in QSEE
03-12 10:11:16.586   767  4666 D QSEECOMAPI: app_arch = 2, total_files = 9
03-12 10:11:16.622   767  4666 D QSEECOMAPI: Loaded image: APP id = 478150660
03-12 10:11:16.625   767  4666 D         : CPPF_ServiceInitialize: end! returns 0
03-12 10:11:16.625   767  4666 D QSEECOMAPI: QSEECom_get_handle sb_length = 0x19000
03-12 10:11:16.626   767  4666 D QSEECOMAPI: App is not loaded in QSEE
03-12 10:11:16.626   767  4666 D QSEECOMAPI: app_arch = 2, total_files = 9
03-12 10:11:16.635   608  1275 W SurfaceFlinger: Attempting to set client state on removed layer: com.google.android.gms/com.google.android.gms.common.account.OriginalAccountChipAccountPickerActivity#0
03-12 10:11:16.635   608  1275 W SurfaceFlinger: Attempting to destroy on removed layer: com.google.android.gms/com.google.android.gms.common.account.OriginalAccountChipAccountPickerActivity#0
03-12 10:11:16.669   767  4666 D QSEECOMAPI: Loaded image: APP id = 478216197
03-12 10:11:16.672   767  4666 D QSAPPSVER: qsapps_get_capabilities: Capability from secure side: 0x1
03-12 10:11:16.672   767  4666 D QSAPPSVER: qsapps_get_capabilities: returns 0
03-12 10:11:16.691   644   653 D QC-time-services: Daemon: Connection accepted:time_genoff
03-12 10:11:16.691   644 22781 D QC-time-services: Daemon:Received base = 13, unit = 1, operation = 2,value = 0
03-12 10:11:16.691   644 22781 D QC-time-services: Daemon:genoff_opr: Base = 13, val = 0, operation = 2
03-12 10:11:16.691   644 22781 D QC-time-services: offset is: 1 for base: 13
03-12 10:11:16.691   644   653 E QC-time-services: Daemon: Time-services: Waiting to acceptconnection
03-12 10:11:16.691   644   653 D QC-time-services: Daemon: Connection accepted:time_genoff
03-12 10:11:16.691   644 22782 D QC-time-services: Daemon:Received base = 13, unit = 1, operation = 1,value = 0
03-12 10:11:16.691   644 22782 D QC-time-services: Daemon:genoff_opr: Base = 13, val = 0, operation = 1
03-12 10:11:16.691   644 22782 D QC-time-services: Daemon: genoff get for 13
03-12 10:11:16.691   644 22782 D QC-time-services: Daemon:Value read from QTimer mseconds = 3360935727
03-12 10:11:16.691   644 22782 D QC-time-services: Daemon:Value read from RTC mseconds on boot = 249831000
03-12 10:11:16.691   644 22782 D QC-time-services: Daemon:Value read from QTimer mseconds = 3360935727
03-12 10:11:16.691   644 22782 D QC-time-services: Daemon:Value read from generic offset = 1501749260691
03-12 10:11:16.691   644 22782 D QC-time-services: Daemon:Delta read on boot mseconds = 249816257
03-12 10:11:16.691   644 22782 D QC-time-services: Daemon:Final Time = 1505360012675
03-12 10:11:16.691   644   653 E QC-time-services: Daemon: Time-services: Waiting to acceptconnection
03-12 10:11:16.703   608   710 W SurfaceFlinger: Attempting to set client state on removed layer: 
com.google.android.gms/com.google.android.gms.common.account.AccountChipAccountPickerActivity#0
03-12 10:11:16.703   608   710 W SurfaceFlinger: Attempting to destroy on removed layer: com.google.android.gms/com.google.android.gms.common.account.AccountChipAccountPickerActivity#0
03-12 10:11:16.703   767  4666 D WVCdm   : [oemcrypto_adapter_dynamic.cpp(592):Initialize] OEMCrypto_Initialize Level 1 success. I will use level 1.
03-12 10:11:16.703   767  4666 D WVCdm   : [crypto_session.cpp(646):Open] CryptoSession::Open: Lock: requested_security_level: Default
03-12 10:11:16.719   608  1275 W SurfaceFlinger: Attempting to set client state on removed layer: Dim Layer for - Task=1189#0
03-12 10:11:16.719   608  1275 W SurfaceFlinger: Attempting to destroy on removed layer: Dim Layer for - Task=1189#0
03-12 10:11:16.720   767  4666 I WVCdm   : [(0):] L3 Terminate.
03-12 10:11:16.721   767  4666 D         : CPPF_CheckMinEncLevelStatus: start!
03-12 10:11:16.721   767  4666 D         : CPPF_CheckMinEncLevelStatus: No change
03-12 10:11:16.721   767  4666 D         : CPPF_CheckMinEncLevelStatus: end!
03-12 10:11:16.721   767  4666 D QSEECOMAPI: QSEECom_dealloc_memory 
03-12 10:11:16.721   767  4666 D QSEECOMAPI: QSEECom_shutdown_app, app_id = 478216197
03-12 10:11:16.722   767  4666 D         : CPPF_ServiceUninitialize: start!
03-12 10:11:16.722   767  4666 D QSEECOMAPI: QSEECom_dealloc_memory 
03-12 10:11:16.722   767  4666 D QSEECOMAPI: QSEECom_shutdown_app, app_id = 478150660
03-12 10:11:16.723   767  4666 D         : CPPF_ServiceUninitialize: end! returns 0
03-12 10:11:16.723   767  4666 I WVCdm   : [cdm_engine.cpp(110):OpenSession] CdmEngine::OpenSession
03-12 10:11:16.724   767 22783 I WVCdm   : [(0):] Level3 Library 4445 Apr 20 2018 14:53:46
03-12 10:11:16.732   767  4666 I WVCdm   : [oemcrypto_adapter_dynamic.cpp(575):Initialize] L3 Initialized. Trying L1.
03-12 10:11:16.733   767  4666 D         : CPPF_ServiceInitialize: start!
03-12 10:11:16.733   767  4666 D QSEECOMAPI: QSEECom_get_handle sb_length = 0x2800
03-12 10:11:16.733   767  4666 D QSEECOMAPI: App is not loaded in QSEE
03-12 10:11:16.733   767  4666 D QSEECOMAPI: app_arch = 2, total_files = 9
03-12 10:11:16.738  9701 10261 W Conscrypt: Could not set socket write timeout: java.net.SocketException: Socket closed
03-12 10:11:16.738  9701 10261 W Conscrypt:     at com.google.android.gms.org.conscrypt.Platform.setSocketWriteTimeout(Platform.java:132)
03-12 10:11:16.738  9701 10261 W Conscrypt:     at com.google.android.gms.org.conscrypt.ConscryptFileDescriptorSocket.setSoWriteTimeout(ConscryptFileDescriptorSocket.java:926)
03-12 10:11:16.761  9701 10261 W Conscrypt: Could not set socket write timeout: java.net.SocketException: Socket closed
03-12 10:11:16.761  9701 10261 W Conscrypt:     at com.google.android.gms.org.conscrypt.Platform.setSocketWriteTimeout(Platform.java:132)
03-12 10:11:16.761  9701 10261 W Conscrypt:     at com.google.android.gms.org.conscrypt.ConscryptFileDescriptorSocket.setSoWriteTimeout(ConscryptFileDescriptorSocket.java:926)

1 Ответ

0 голосов
/ 14 июня 2019

Чтобы использовать Google Drive API, необходимо установить учетные данные OAuth 2.0 с помощью ключа SHA-1.

справка:
https://developers.google.com/drive/android/auth

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...