问题描述
我正在使用新的Google Drive Android API.这是我从 Google的android-samples回购.
I'm using the new Google Drive Android API. This is the demo code that I've copied from Google's android-samples repo.
GoogleSignInAccount signInAccount = GoogleSignIn.getLastSignedInAccount(this);
if (signInAccount != null && signInAccount.getGrantedScopes().containsAll(requiredScopes)) {
initializeDriveClient(signInAccount);
}
else
{ ... }
我面临的问题是,即使我从云端硬盘中删除了该应用程序,getLastSignedInAccount()
仍在返回该帐户,并且对这些帐户的操作(例如添加文件)仍然成功.我想返回GoogleSignInAccount
对象是可以的,但是它不应允许对其进行操作.我在云端硬盘中再次进行了检查,当API返回成功时(因为我已取消关联该应用程序),没有添加任何文件.这里出了什么问题?
The issue I'm facing is, even if I remove the app from Drive, getLastSignedInAccount()
is still returning the account and the operations (such as adding a file) on the accounts are still succeeding. Returning the GoogleSignInAccount
object is fine, I suppose, but it should not allow the operations on it. I double checked in Drive, there are no files getting added when the API returns success (since I've unlinked the app). What is going wrong here?
是的,当我在设备上手动同步帐户时,它可以正常工作.在这种情况下,尽管getLastSignedInAccount()
返回了该对象,但操作确实失败了.
And yes it worked when I manually synced the account on my device. In that case, though getLastSignedInAccount()
returned the object, the operations did fail.
PS:我正在请求SCOPE_FILE
和SCOPE_APPFOLDER
范围.
PS: I'm requesting SCOPE_FILE
and SCOPE_APPFOLDER
scopes.
推荐答案
这看起来像期望的行为.
This looks like the desired behaivour.
仅在同步之后,GoogleSignIn.getLastSignedInAccount(this)
才知道,而不是在此之前.如您所见,此方法是非阻塞的.
Only after the sync, will the GoogleSignIn.getLastSignedInAccount(this)
get to know, not before that. As you can see, this method is non-blocking.
作为改进,用于执行操作的API调用应返回类似403 UNAUTHORIZED
As an improvement, the API calls for performing operations should return something like a 403 UNAUTHORIZED
这篇关于即使删除该应用,Google Drive Android API也会返回成功的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!