如果玩家啟動了已啟用自動登入功能的遊戲,使用者就會登入遊戲,無須與登入提示互動。玩家可以在 Google Play 遊戲應用程式或遊戲顯示的初始登入提示中,啟用自動登入功能。
多帳戶登入服務
Play 遊戲服務可以為 Android 玩家提供遊戲身分,但是這不一定是使用者唯一可以使用的身分。您可以同時使用 Play 遊戲服務、社群網路 ID 以及您自己的遊戲內部 ID 系統登入玩家。
玩家 ID
玩家 ID 是 Play 遊戲服務玩家帳戶的 ID。只要遊戲使用 Play 遊戲服務登入程序,即可擷取任何玩家的玩家 ID。您的遊戲用戶端整合、遊戲伺服器整合和雲端儲存服務可以使用 ID,安全地從 Play 遊戲服務存取玩家資料。
使用者在多部裝置上玩遊戲時,玩家 ID 會保持一致,但不同遊戲之間的玩家 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"]],["上次更新時間: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)."]]