【问题标题】:GoogleAuthUtil.getToken(Unknown Source) Unknown ExceptionGoogleAuthUtil.getToken(Unknown Source) 未知异常
【发布时间】:2015-03-17 06:45:57
【问题描述】:

我有一个函数尝试获取令牌以查询 Drive API:

private void getAuthTokenBlocking() {
    try {
        Account account =  AccountManager.get(sActivity).getAccountsByType(GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE)[0];
        sToken = GoogleAuthUtil.getToken(sActivity, account.name, DriveScopes.DRIVE_READONLY);
    } catch (GooglePlayServicesAvailabilityException playEx) {
        Dialog alert = GooglePlayServicesUtil.getErrorDialog(
                playEx.getConnectionStatusCode(),
                sActivity,
                AUTH_REQUEST_CODE);
        alert.show();
    } catch (UserRecoverableAuthException userAuthEx) {
        userAuthEx.printStackTrace();
    } catch (IOException transientEx) {
        transientEx.printStackTrace();
    } catch (GoogleAuthException authEx) {
        authEx.printStackTrace();
    }
}

但我总是收到以下错误:

com.google.android.gms.auth.GoogleAuthException: Unknown
com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)

我已经尝试了所有我能看到的解决方案,包括在范围前加上“oauth2:”。

【问题讨论】:

标签: android authentication google-oauth google-oauth-java-client


【解决方案1】:

我想通了;我实际上是从两个不同的平台构建并在 github 上同步的。但是,两个调试密钥都存储在本地。因此,我在另一台机器上工作时,使用来自一台机器的签名设置了令牌检索。同步此密钥后,我就可以进行身份​​验证了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-01-31
    • 2017-12-23
    • 2015-05-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-09
    • 1970-01-01
    相关资源
    最近更新 更多