当玩家启动启用了自动登录功能的游戏时,他们无需与登录提示互动即可登录游戏。玩家可以在 Google Play 游戏应用中或在游戏中显示的初始登录提示中启用自动登录功能。
多账号登录服务
Play 游戏服务为 Android 玩家提供游戏身份,但此身份不一定是与用户关联的唯一身份。您可以同时使用 Play 游戏服务、社交网络 ID 和您自己的游戏内 ID 系统为玩家提供登录选项。
玩家 ID
玩家 ID 是 Play 游戏服务玩家账号的标识符。您的游戏可以检索使用 Play 游戏服务登录功能登录游戏的任何玩家的玩家 ID。您的游戏客户端集成、游戏服务器集成和云端存档服务可以使用玩家 ID 安全地访问 Play 游戏服务中的玩家数据。
当用户在多个设备上玩同一款游戏时,玩家 ID 是一致的。但是,不同游戏之间不一定会始终保持一致。
如需了解详情,请参阅新一代玩家 ID。
OAuth 范围
Play 游戏服务依赖 OAuth 系统来允许玩家授权您的游戏访问他们的账号。Play 游戏服务针对游戏提供唯一范围 (games-lite),如果您的游戏使用游戏存档功能,将依赖另一个范围 (drive.appdata)。通过游戏存档功能,您可以访问用户的 Google 云端硬盘账号,游戏数据便存储在此处。
在玩家使用登录服务登录您的游戏后,您的后端游戏服务器可以直接与 Play 游戏服务服务器通信,以访问玩家的 ID、个人资料、好友列表和其他 Play 游戏服务数据。这需要由 Play 游戏服务 SDK 提供的服务器授权代码。您的服务器可以结合使用授权代码与 Play 游戏服务 REST API 来与 Play 游戏服务服务器进行安全通信。
[[["易于理解","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"]],["最后更新时间 (UTC):2025-08-21。"],[],[],null,["# Sign-in\n\n| **Note:** This guide is for the Play Games Services v2 SDK. For information on the previous version of this SDK, see the [Play Games Services v1\n| documentation](/games/pgs/v1/signin).\n\nGoogle Play Games Services sign-in mechanism serves the purpose of authenticating players and\nproviding them with distinct Android gaming identities ([player ID](#player-id)).\n\nThis platform-level player ID facilitates the seamless continuation of gameplay\nacross multiple devices, thereby establishing a cohesive connection between the\ngame and the player. In comparison to alternative centralized systems, players\nare more willing to use this identity for the purpose of sign-in.\n\nFurthermore, the sign-in process offers a reliable identifier for cloud save\nsystems. Players are able to do the following:\n\n- Resume their progress in the game following a change or reset of their device.\n- Engage in the game across multiple devices, enabling seamless transitions between smartphones and Chromebooks.\n- Uninstall and reinstall the game.\n\nDevelopers have the option of either using the player ID as a key for their\nown cloud save solution, or using the built-in\n[Saved Games service](/games/pgs/savedgames).\n\nPlay Games Services (PGS) supports automatic sign-in, a zero-friction way to\nsign in players.\n\nSign-in with Play Games Services is an effective way to provide\nplayers with a strong identity without the need to implement additional features\nlike leaderboards or saved games.\nThis low-friction approach makes it easier for players to engage with your game\nand create a personalized experience.\n\nPlay Games Services v2 SDK\n--------------------------\n\nThe Play Games Services v2 SDK offers several enhancements over v1 in terms of\nuser sign-in:\n\nFor users:\n\n- Improved user experience: After selecting a default account, users are automatically signed in without encountering additional prompts.\n\nFor developers:\n\n- Simplified code implementation: Client-side code no longer requires handling of the sign-in or sign-out flow. Login is automatically triggered at game launch, and account management is streamlined within OS settings.\n\nLogin request quota\n-------------------\n\nThere is a daily quota for login requests with Play Games Services. For more\ninformation, see\n[Managing your daily quota](/games/pgs/quota#manage-daily-quota).\n\nRecommended sign-in flow\n------------------------\n\nIn order to successfully sign players into your game, use the following\nsign-in flow:\n\n1. During the startup sequence of your game, [Automatic sign-in](#automatic-sign-in) will trigger, attempting to login the user or create a new account.\n2. If automatic sign-in does not work or the user declines, then show a manual sign-in button in case the user would like to login later on.\n\nAutomatic sign-in\n-----------------\n\nWhen a player launches a game with automatic sign-in enabled, they are signed\ninto the game without interacting with the sign-in prompt. Players can enable\nautomatic sign-in in the Google Play Games app, or in the initial sign-in\nprompt displayed in your game.\n\nMultiple sign-in services\n-------------------------\n\nPlay Games Services provides a gaming identity for Android players, but it\ndoesn't need to be the only identity connected to your users. You can sign in\nplayers using Play Games Services, a social network ID, and your own in-game ID\nsystem all at the same time.\n\nPlayer ID\n---------\n\nA player ID is an identifier for a Play Games Services player account. Your\ngame can retrieve a player ID for any player that signs into your game using\nPlay Games Services sign-in. Your\n[game client integration](#client-integration),\n[game server integration](#secure-access), and\n[cloud-save service](/games/pgs/savedgames) can use the ID to securely access\nplayer data from Play Games Services.\n\nA player ID is consistent for a user when they play your game on multiple\ndevices. However, it is not always consistent between games.\nFor more information, see\n[next generation Player IDs](/games/pgs/next-gen-player-ids).\n\nOAuth Scopes\n------------\n\nPlay Games Services relies on the\n[OAuth system](https://developers.google.com/identity/protocols/OAuth2)\nto allow players to give your game access to their account. Play Games Services\nhas a unique scope for games (`games-lite`) and relies on another scope\n(`drive.appdata`) if your game uses the saved games feature. The saved games\nfeature gives access to the user's Google Drive account, which is where the game\ndata is stored.\n\nWhen using the Play Games Services v2 SDK, you can request extra\n[OAuth scopes](https://developers.google.com/identity/protocols/googlescopes).\nIf you need extra OAuth scopes, we recommend calling `requestServerSideAccess`.\nFor more information, see\n[get the server auth code](/games/pgs/android/server-access#get-auth-code) or [retrieve server authentication codes](/games/pgs/unity/unity-start#retrieve-auth-codes).\n\nRecall API\n----------\n\nThe [Recall API](/games/pgs/recall) lets games manage links between PGS users\nand their in-game accounts by storing recall tokens with Google servers. To\nlearn more about enabling this feature, see [Integrate the PGS Recall API\nwithin your game](/games/pgs/recall/recall-setup).\n\nGame client integration\n-----------------------\n\nWhen integrating sign-in into your game project, we recommend the following\nuser flow:\n\n1. During the startup sequence of your game,\n [automatic sign-in](#automatic-sign-in) launches and attempts to login the\n user or create a new account.\n\n2. If automatic sign-in does not work or the user declines, then show a manual\n sign-in button in case the user would like to login later.\n\nFor information about integrating sign-in in your game project, see the get\nstarted guide for your project type:\n\n- [C and C++ games](/games/pgs/cpp/cpp-start)\n\n- [Unity games](/games/pgs/unity/unity-start)\n\n- [Java games](/games/pgs/android/android-signin)\n\nGame server integration\n-----------------------\n\nAfter a player signs into your game using the Sign-in services, your backend\ngame server can communicate directly with Play Games Services servers to access\na player's ID, profile, friends list, and other Play Games Services data. This\nrequires a server authorization code that is provided by the\nPlay Games Services SDK. Your server can use the authorization code along\nwith the Play Games Services\n[REST API](/games/services/web/api/rest) to securely\ncommunicate with Play Games Services servers.\n\nFor more information, see\n[Server-side access to Play Games Services](/games/pgs/android/server-access)."]]