[英]Do i have to create 2 Google Api Client for Drive.API and Auth.GOOGLE_SIGN_IN_API?
我有一个Android应用程序,可以通过google登录/注销,这就是为什么我使用以下Google Api Client的原因:
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this, this)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.addOnConnectionFailedListener(this)
.build();
但是当我想为驱动器连接设置此Google Api客户端时,如下所示:
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this, this)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.addApi(Drive.API)
.addOnConnectionFailedListener(this)
.build();
我有 :
onConnectionFailed:ConnectionResult{statusCode=INTERNAL_ERROR, resolution=null, message=null}
如果我要登出导致GoogleApiClient未连接(由于connectionFailed),然后发生错误
我的文件夹应用程序中有我的配置文件,请在Google Developer Console中查看所有信息,但我没有。
您只需要一个GoogleApiClient,重要的是通过使用requestScopes(new Scope(Scopes.DRIVE_APPFOLDER))
定义范围,即,
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(getString(R.string.default_web_client_id))
.requestScopes(new Scope(Scopes.DRIVE_APPFOLDER))
.requestEmail()
.build();
mGoogleApiClient = new GoogleApiClient.Builder(getApplicationContext())
.enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.addApi(Drive.API)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.