从旧版 Google 登录服务迁移到 Credential Manager 和 AuthorizationClient
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
从 Google Sign-In for Android 迁移到 Android Credential Manager,以简化应用的身份验证体验,并使您的开发实践能够满足未来的需求。Google Sign-In for Android 已废弃,并将从 Google Play 服务 Auth SDK 中移除。(com.google.android.gms:play-services-auth
) 在 2025 年。
对于身份验证,开发者应将其 Android 项目迁移到 Credential Manager,该工具完全支持“使用 Google 账号登录”的一键快捷功能和按钮流程。如需了解详情,请参阅我们的博文。
对于需要访问 Google 存储的用户数据(例如 Google 云端硬盘)的授权操作,请使用 AuthorizationClient API。
将身份验证迁移到 Credential Manager API
Credential Manager 提供简化、统一的 API,实现了对新型功能和实践的支持,同时提升了用户的身份验证体验,因此与旧版 Google 登录 Android 相比,它具有多项关键优势:
- 使用 Credential Manager 构建的简化流程可将平均注册和登录时间缩短多达 50%。
- Credential Manager 可支持多账号登录方法(包括使用 Google 账号登录、通行密钥和密码)。
- Credential Manager 是一个单一的统一 API,可在各种 Android 设备上提供更一致的界面,符合不断发展的安全标准,并简化开发流程。
- Credential Manager 会在所有身份验证方法中提供一致、统一的用户体验。
- 从 Android 14 开始,Credential Manager 支持第三方密码和通行密钥提供程序,让用户可以选择首选的凭据提供程序。
- Credential Manager 完全支持使用 Google 账号登录按钮,因此开发者可以直接将其添加到现有流程中。
- Credential Manager 支持一键登录功能,因此开发者可以直接提示用户只需轻轻一点即可使用其 Google 账号登录。
如需开始 Credential Manager 集成,请阅读开发者指南。阅读使用通行密钥的身份验证用户体验,了解应如何设计身份验证流程。如需了解有关一键快捷登录或“使用 Google 账号登录”按钮的实现详情,请参阅将 Credential Manager 与“使用 Google 账号登录”功能集成指南。
将授权迁移到 AuthorizationClient API
与旧版 Google 登录相比,身份验证和授权功能现在是作为两个独立的流程提供的。Credential Manager 是您在 Android 设备上用于身份验证的 API。对于授权操作(例如访问 Google 云端硬盘等服务),请使用 AuthorizationClient API。这种分离有助于您将用户流程映射到用户意图,以便用户可以使用其 Google 账号注册或登录,并且您可以在应用需要时单独提供 Google 账号授权权限,而不是仅在登录时提供。
如需详细了解授权,请参阅授权访问用户数据指南,并查看 AuthorizationClient API 文档。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[null,null,["最后更新时间 (UTC):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."]]