[英]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.