簡體   English   中英

Android使用GoogleApiClient獲取Google驅動器的令牌

[英]Android get token of google drive using GoogleApiClient

我在Android應用程序中使用Google Drive API。 我正在使用GoogleApiClient,如下所示:

private GoogleApiClient buildApiClient() {
    return new GoogleApiClient.Builder(this)
            .addApi(Drive.API)
            .addScope(Drive.SCOPE_FILE)
            .addScope(Drive.SCOPE_APPFOLDER) // required for App Folder sample
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .build();
}

我需要獲取訪問令牌。 如果可能,如何使用GoogleApiClient進行此操作? 還是我需要另一種方式?

此處查看Google for Android文檔。 根據文檔GoogleAuthUtil為Google帳戶提供ClientLogin,OAuth2,ID或脫機令牌。 話雖如此,如果您改為使用Google Play服務庫來訪問Google API(例如Play游戲服務),則不需要OAuth 2.0令牌,而可以使用GoogleApiClient訪問這些服務。 有關更多信息,請閱讀訪問Google Play服務API 您可以決定哪個更適合您的用例。 祝你好運!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM