Android:Google Drive API getToken GoogleAuthException

时间:2014-08-27 08:44:24

标签: android google-drive-api google-drive-android-api

我将Google云端硬盘API集成到了我的Android应用中,但最近我发现这停止了工作,之前一切正常。现在我得到了GoogleAuthException:getToken()函数未知。我使用Android 4.4.4在Nexus 7上进行了测试。我的应用程序是使用Google API 4.2.2编译的。

这是我的代码:

public Account getAccount() {
    if (mSelectedAccountName != null) {
        return mAccountManager.getAccountByName(mSelectedAccountName);
    }

    return null;
}

private void checkIfUserIsAuthenticated(Activity context, boolean showAuthActivity) {
    if (mSelectedAccountName != null) {
        try {
            Account account = getAccount();

            if (account != null) {
                mCredential.setSelectedAccountName(mSelectedAccountName);
                mService = getDriveService(mCredential);
                mCredential.getToken();
                mIsUserAuthenticated = true;
            }
        } catch (UserRecoverableAuthException e) {
            mIsUserAuthenticated = false;

            if (showAuthActivity) {
                showAuthenticationActivity(context, e.getIntent());
            }
        } catch (IOException e) {
            e.printStackTrace();
        } catch (GoogleAuthException e) {
            e.printStackTrace();
            mIsUserAuthenticated = false;
        }
    }
}

有人知道会发生什么吗?

0 个答案:

没有答案