從舊版 Google 登入遷移至 Credential Manager 和 AuthorizationClient
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
從 Android 版 Google 登入改用 Android Credential Manager,即可簡化應用程式的驗證體驗,並確保開發作業符合未來需求。Google Sign-In for Android 已淘汰,並將從 Google Play 服務驗證 SDK 中移除。(com.google.android.gms:play-services-auth
) 後的 2025 年。
針對驗證,開發人員應將 Android 專案遷移至 Credential Manager,後者完全支援「使用 Google 帳戶登入」的 One Tap 和按鈕流程。詳情請參閱網誌文章。
如果授權動作需要存取 Google 儲存的使用者資料 (例如 Google 雲端硬碟),請使用 AuthorizationClient API。
將驗證機制遷移至 Credential Manager API
Credential Manager 提供簡化且統一的 API,支援新式功能和做法,還可提高使用者的驗證體驗,因此比舊版 Android 版 Google 登入功能有幾項重要優勢:
- 使用 Credential Manager 建立的簡化流程可縮短註冊和登入的平均時間,最多可縮短 50%。
- Credential Manager 支援多種登入方法,包括使用 Google 帳戶登入、密碼金鑰和密碼。
- Credential Manager 是單一整合式 API,可在各 Android 裝置上提供更一致的使用者介面,並配合不斷演進的安全標準,簡化開發程序。
- Credential Manager 為所有驗證方法提供了一致的整合式使用者體驗。
- 自 Android 14 起,Credential Manager 支援第三方密碼和密碼金鑰供應器,讓使用者選取偏好的憑證供應器。
- Credential Manager 完全支援「使用 Google 帳戶登入」按鈕,因此開發人員可以直接將這個按鈕加入現有的流程。
- 憑證管理工具支援 One Tap 功能,因此開發人員可以直接提示使用者輕觸一次即可登入 Google 帳戶。
如要開始整合憑證管理工具,請參閱開發人員指南。請參閱密碼金鑰驗證使用者體驗,瞭解如何設計身分流程。如要瞭解 OneTap 或「使用 Google 帳戶登入」按鈕的導入詳細資訊,請參閱「將 Credential Manager 與『使用 Google 帳戶登入』功能整合」指南。
將授權權限遷移至 AuthorizationClient API
與舊版 Google 登入相比,驗證和授權功能現在可透過兩個獨立且不同的流程使用。Credential Manager 是您在 Android 上用於驗證的 API。如要執行授權動作 (例如存取 Google 雲端硬碟等服務),請使用 AuthorizationClient API。這項分隔功能可協助您將使用者流程對應至使用者意圖,讓使用者可以使用 Google 帳戶註冊或登入,並在應用程式需要時,分別提供 Google 帳戶的授權權限,而非僅在登入時提供。
如要進一步瞭解授權,請參閱「授權存取使用者資料」指南,並查看 AuthorizationClient API 說明文件。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],null,["# Migrate from legacy Google Sign-In to Credential Manager and AuthorizationClient\n\nMigrate from [Google Sign-In for Android](https://developers.google.com/identity/sign-in/android/start-integrating) to Android Credential Manager to\nstreamline your app's authentication experience and future-proof your\ndevelopment practices. Google Sign-In for Android is deprecated and will be\nremoved from the [Google Play Services Auth SDK](https://maven.google.com/web/index.html?q=play-services-auth#com.google.android.gms:play-services-auth).\n(`com.google.android.gms:play-services-auth`) in 2025.\n\nFor **authentication** , developers should migrate their Android projects to\n[Credential Manager](#authentication), which fully supports One Tap and\nbutton flows for Sign in with Google. See our [blog post](https://android-developers.googleblog.com/2024/09/streamlining-android-authentication-credential-manager-replaces-legacy-apis.html) for details.\n\nFor **authorization** actions that need access to user data stored by Google\nsuch as Google Drive, use the [AuthorizationClient API](#authorization).\n\nMigrate authentication to the Credential Manager API\n----------------------------------------------------\n\nWith a streamlined, unified API that enables support for modern features and\npractices while improving the authentication experience for your users,\nCredential Manager offers several key advantages over legacy Google Sign-In for\nAndroid:\n\n- Simplified and streamlined flows built with Credential Manager have been shown to [reduce average sign-up and sign-in times](https://developers.googleblog.com/2023/10/how-kayak-reduced-sign-in-time-and-improved-security-with-passkeys.html) by up to 50%.\n- Credential Manager integrates support for multiple sign-in methods, including [Sign in with Google](/training/sign-in/credential-manager), [passkeys](https://developers.google.com/identity/passkeys) and passwords.\n- Credential Manager is a single, unified API that provides a more consistent user interface across Android devices, aligns with evolving security standards, and simplifies your development process.\n- Credential Manager provides a consistent, unified [user experience](/design/ui/mobile/guides/patterns/passkeys) across all authentication methods.\n- Starting with Android 14, Credential Manager supports third-party password and passkey providers, allowing users to select their preferred credential provider.\n- Credential Manager fully supports the [Sign in with Google](/training/sign-in/credential-manager) button, so developers can drop this directly into existing flows.\n- Credential Manager supports One Tap capabilities, so developers can directly prompt users to sign in with their Google Account with a single tap.\n\nTo begin your Credential Manager integration, [read the developer guide](/training/sign-in/passkeys).\nRead about [authentication user experience with passkeys](/design/ui/mobile/guides/patterns/passkeys) to understand how\nyour identity flows should be designed. Read the [Integrate Credential Manager\nwith Sign in with Google](/training/sign-in/credential-manager) guide for implementation details on One Tap or the\nSign in with Google button.\n\nMigrate authorization to the AuthorizationClient API\n----------------------------------------------------\n\nIn contrast with legacy Google Sign-In, the authentication and authorization\nfunctions are now available as two separate and distinct flows. Credential\nManager is the API you use for ***authentication*** on Android. For\n***authorization*** actions, such as accessing a service like Google Drive, use\nthe AuthorizationClient API. This separation helps you map user flows to user\nintent, so that your users can sign up or sign in with their Google Accounts,\nand you can separately provide authorization permissions from their Google\nAccount when they are needed by the application as opposed to login time alone.\n\nTo learn more about authorization, read the [Authorize Access to User Data](https://developers.google.com/identity/sign-in/android/authorize-access)\nguide, and check out the [AuthorizationClient API](https://developers.google.com/android/reference/com/google/android/gms/auth/api/identity/AuthorizationClient) documentation."]]