從舊版 Google 登入遷移至 Credential Manager 和 AuthorizationClient

Android 版 Google 登入遷移至 Android Credential Manager,簡化應用程式的驗證體驗,並確保開發做法能與時俱進。Android 適用的 Google 登入功能已淘汰,並將從 Google Play 服務驗證 SDK 中移除。(com.google.android.gms:play-services-auth)。

針對驗證,開發人員應將自己的 Android 專案遷移至 Credential Manager

如果是需要存取 Google 如 Google 雲端硬碟等 Google 儲存使用者資料的授權動作,請使用 AuthorizationClient API

將驗證遷移至 Credential Manager API

與 Android 版 Google 登入相比,Credential Manager 提供幾個簡單好用的整合式 API,可支援新式功能與做法,同時改善使用者的驗證體驗:

  • 目前已透過 Credential Manager 建構簡化流程,讓平均註冊和登入時間減少 50%。
  • Credential Manager 整合了多種登入方法,包括使用 Google 帳戶登入密碼金鑰和密碼。
  • Credential Manager 是整合式的 API,可在所有 Android 裝置上提供更一致的使用者介面,符合不斷演進的安全性標準,並簡化開發程序。
  • Credential Manager 為所有驗證方法提供了一致的整合式使用者體驗
  • 從 Android 14 開始,Credential Manager 支援第三方密碼和密碼金鑰提供者,可讓使用者選取偏好的憑證提供者。
  • Credential Manager 完全支援「使用 Google 帳戶登入」按鈕,因此開發人員可將這個按鈕直接放到現有流程中。
  • Credential Manager 支援 One Tap 功能,可讓開發人員直接提示使用者輕觸一下即可登入 Google 帳戶。

如要開始整合 Credential Manager,請參閱開發人員指南。請參閱「密碼金鑰的驗證使用者體驗」一文,瞭解應如何設計身分流程。如要進一步瞭解 One Tap 或「使用 Google 帳戶登入」按鈕,請參閱整合 Credential Manager 與「使用 Google 帳戶登入」功能指南。

將授權遷移至 AuthorizationClient API

相較於舊版 Google 登入,驗證和授權功能現在分為兩個獨立且不同的流程。Credential Manager 是用於在 Android 上進行驗證的 API。對於授權動作 (例如存取 Google 雲端硬碟等服務),請使用 AuthorizationClient API。這種區隔可協助您將使用者流程對應至使用者意圖,方便使用者透過 Google 帳戶註冊或登入。此外,您可以在應用程式需要時,另外提供他們 Google 帳戶的授權權限,而非單獨提供登入時間。

如要進一步瞭解授權,請參閱授權存取使用者資料指南,並參閱 AuthorizationClient API 說明文件。