> For the complete documentation index, see [llms.txt](https://docs.candy-smith.com/main/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.candy-smith.com/main/match-3-kit-home-design/services/authentication-setup.md).

# Authentication Setup

The kit uses **Unity Authentication** for player accounts. Cloud Save and Unity Leaderboards use the Unity `PlayerId` created by this service.

Configure providers in **Unity Dashboard → LiveOps → Authentication → Identity Providers** for the `production` environment.

### Android: Google Play Games

Google Play Games is already integrated in the kit through the included plugin in `Assets/GooglePlayGames`.

If the plugin is not included in your copy of the kit, download it from the [official Google Play Games Plugin for Unity releases](https://github.com/playgameservices/play-games-plugin-for-unity/releases). The kit currently uses plugin version `2.1.0`; do not import a second copy or upgrade the plugin without checking Unity/Android compatibility.

1. In Google Play Console, create or configure the Play Games project for:

   `com.candysmith.homedesignmatch3kit`
2. Configure the Android OAuth client with the package name and SHA-1 fingerprints for all signing certificates used for testing.
3. Create a Web OAuth client and add the test accounts in Play Console.
4. In Unity, open **Project settings → Services →Authentication →Add Google Play Games →**  paste **Client ID** and **Client secret** from the Play Console.
5. In Unity Authentication, add **Google Play Games / Google Play Services** and enter the Web client ID and Web client secret.
6. Test a signed APK or an AAB from an internal testing track on a physical Android device.

Register the debug, release/upload, and Google Play App Signing certificates when applicable.

Reference: [Unity Google Play Games Authentication](https://docs.unity.com/en-us/authentication/platform-signin/google-play-games).

### Android: Facebook Login

1. Create a Meta application and add **Facebook Login**.
2. Configure the Android package name and key hashes for the signing certificates.
3. Add the Facebook/Meta Unity SDK.
4. Add Facebook as an Identity Provider in Unity Dashboard using the Meta App ID and App Secret.
5. Add test users while the Meta application is in development mode.

Never store the Meta App Secret in the Unity project or Android client.

Reference: [Unity Facebook Authentication](https://docs.unity.com/en-us/authentication/platform-signin/facebook).

### Standard Google Sign-In

Standard Google Sign-In is separate from Google Play Games. It requires an external SDK that returns a Google ID token, a configured Google Identity Provider in Unity Dashboard, and the `SignInWithGoogleAsync` Unity Authentication flow.

The current Android Google button uses Google Play Games. Standard Google Sign-In is not included in the kit.

Reference: [Unity Google Authentication](https://docs.unity.com/en-us/authentication/platform-signin/google).

### Apple Sign In

Apple Sign In is configured for iOS:

1. Create an Apple App ID for the iOS Bundle ID.
2. Enable **Sign in with Apple**.
3. Add an Apple Sign In SDK to Unity.
4. Configure the Apple Identity Provider in Unity Dashboard.
5. Pass the Apple ID token to Unity Authentication.

The Unity Apple provider does not support the Apple Service ID and Android authorization-code flow. Apple login on Android requires a separate web/backend or custom OIDC solution.

Reference: [Unity Apple Authentication](https://docs.unity.com/en-us/authentication/platform-signin/apple).

### Account linking

Use the provider **Link** operation for a player who already has an anonymous account. This preserves the existing Unity `PlayerId`, leaderboard score, and Cloud Save data.

Use **Sign-In** when returning to an existing provider account on another device.

Google Play Games linking is already implemented. Apple, Facebook, and standard Google require their SDK token flow and linking implementation before enabling those buttons.
