Bob*_*der 7 android google-play-services google-drive-android-api
我连接GoogleApiClient以用于Google云端硬盘.我像这样构建客户端:
GoogleApiClient.Builder(this)
.addApi(Drive.API)
.addScope(Drive.SCOPE_FILE)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
Run Code Online (Sandbox Code Playgroud)
我的经验是,第一次为此客户端发出连接请求时,会显示AccountPicker对话框并显示Google云端硬盘的同意屏幕.如果用户选择一个帐户,同意并且连接成功完成,则AccountManager或某些相关功能会将所选帐户保存为默认帐户,并将驱动器范围的凭据(OAuth令牌?)保存.在后续连接请求中,为了方便用户,使用保存的值,并且用户没有看到用于帐户选择或同意的UI.
对于开发测试,我希望能够清除默认帐户和保存的凭据,以便我可以执行连接失败解决处理.我还没有办法做到这一点.我尝试了这个没有成功:
String driveScope = "https://www.googleapis.com/auth/drive.file";
String tokenType = "oauth2:" + driveScope;
AccountManager.get(this).invalidateAuthToken(
GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE, tokenType);
Run Code Online (Sandbox Code Playgroud)
ian*_*ake 10
这听起来像你应该调用clearDefaultAccountAndReconnect()在你GoogleApiClient清除选定的帐户信息.
| 归档时间: |
|
| 查看次数: |
5011 次 |
| 最近记录: |