【问题标题】:How to unlink an app from google drive account如何从谷歌驱动帐户取消链接应用程序
【发布时间】:2014-12-18 16:17:10
【问题描述】:

我正在通过 google play 服务链接我的应用程序 - drive api。在我尝试取消链接我的申请表用户的谷歌驱动器帐户之前工作正常。我找到了一种使用 Plus API 之类的方法;

mApi = new GoogleApiClient.Builder(context)
    .addApi(Drive.API)
    .addApi(Plus.API)
    .addScope(Drive.SCOPE_APPFOLDER)
    .addConnectionCallbacks(this)
    .addOnConnectionFailedListener(this)
    .build();
...
...
Plus.AccountApi.clearDefaultAccount(mApi);
mApi.disconnect();

但这实际上对我没有多大帮助。当我将我的应用重新链接到谷歌驱动器时,帐户选择意图没有出现。 (我的帐户没有激活 Google Plus 服务!)

还有其他方法可以取消应用与 google-drive 的链接。我想知道为什么 Drive::DriveApi::clearDefaultAccount 不存在?

编辑:

好吧,作为一种解决方法;

mApi.clearDefaultAccountAndReconnect();
mApi.disconnect();

这将清除身份验证数据并且 mApi.disconnect() 不会让重新连接...我仍然想知道是否有任何优雅的解决方案...

【问题讨论】:

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


    【解决方案1】:

    如您所见,clearDefaultAccount() 方法已被弃用并替换为clearDefaultAccountAndReconnect()

    clearDefaultAccountAndReconnect() 方法会删除在 Google Play 服务中为您的应用设置的默认帐户。对connect() 的后续调用将返回一个解析意图,让用户选择不同的帐户。

    如果用户选择相同的帐户,则不需要同意,因为对应用程序的访问权限不会被撤销。还应为用户提供使用revokeAccessAndDisconnect(GoogleApiClient) 撤销访问权限的选项。

    您可以在链接中找到更多信息:https://developer.android.com/reference/com/google/android/gms/plus/Account.html

    希望对你有帮助。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-03-09
    • 1970-01-01
    • 1970-01-01
    • 2018-05-25
    • 1970-01-01
    • 2011-11-17
    • 1970-01-01
    • 2013-09-05
    相关资源
    最近更新 更多