### Unity Package Manager Dependency Configuration
Source: https://context7.com/thaina/google-signin-unity/llms.txt
Configuration file for Unity Package Manager to install the Google Sign-In plugin and its dependencies. It specifies Git URLs for custom packages and version for Unity's JSON package.
```json
{
"dependencies": {
"com.google.external-dependency-manager": "https://github.com/googlesamples/unity-jar-resolver.git?path=upm",
"com.google.signin": "https://github.com/Thaina/google-signin-unity.git#newmigration",
"com.unity.nuget.newtonsoft-json": "3.2.1"
}
}
```
--------------------------------
### Build Unity Plugin Shortcut (Linux/Mac)
Source: https://github.com/thaina/google-signin-unity/blob/newmigration/README.md
This is a shortcut command for Linux and Mac users to build the Google Sign-In Unity plugin. It performs the same actions as the Gradle command, including building the support AAR library, packaging the plugin, and creating a sample package.
```bash
./build_all
```
--------------------------------
### Unity Package Manager Dependencies (JSON)
Source: https://github.com/thaina/google-signin-unity/blob/newmigration/README.md
Specifies the dependencies required for the Google Sign-In Unity plugin using the Unity Package Manager format. It includes the external dependency manager and the specific branch tag for the Google Sign-In plugin.
```json
{
"dependencies": {
"com.google.external-dependency-manager": "https://github.com/googlesamples/unity-jar-resolver.git?path=upm",
"com.google.signin": "https://github.com/Thaina/google-signin-unity.git#newmigration",
...
}
}
```
--------------------------------
### Build Unity Plugin with Gradle
Source: https://github.com/thaina/google-signin-unity/blob/newmigration/README.md
This command builds the Google Sign-In Unity plugin using Gradle. It compiles the support AAR library, packages the plugin into a .unitypackage, and creates a separate package for the sample scene and script. Lint warnings are treated as errors during the build.
```bash
./gradlew -PlintAbortOnError build_all
```
--------------------------------
### Configuring Google Sign-In Dependencies (XML)
Source: https://github.com/thaina/google-signin-unity/blob/newmigration/README.md
This XML file in Unity allows for the customization of Google Sign-In dependencies. Uncommenting specific entries, like the 'play-services-games' dependency, enables features such as using the Play Games Services Gamer profile for signing in.
```xml
```
--------------------------------
### iOS Plist Configuration for Google Sign-In (XML)
Source: https://github.com/thaina/google-signin-unity/blob/newmigration/README.md
Example XML structure for an Info.plist file on iOS, used to configure Google Sign-In. It shows the required CLIENT_ID and REVERSED_CLIENT_ID, and optionally WEB_CLIENT_ID for server auth codes. This format is typically downloaded from the Google Cloud Console.
```xml
CLIENT_ID
{YourCloudProjectID}-yyyyyYYYYyyyyYYYYYYYYYYYYYYyyyyyy.apps.googleusercontent.com
REVERSED_CLIENT_ID
com.googleusercontent.apps.{YourCloudProjectID}-yyyyyYYYYyyyyYYYYYYYYYYYYYYyyyyyy
PLIST_VERSION
1
BUNDLE_ID
com.{YourCompany}.{YourProductName}
WEB_CLIENT_ID
{YourCloudProjectID}-zzzZZZZZZZZZZZZZZzzzzzzzzzzZZZzzz.apps.googleusercontent.com
```
--------------------------------
### Configure Google Sign-In in Unity (C#)
Source: https://github.com/thaina/google-signin-unity/blob/newmigration/README.md
Sets up the Google Sign-In configuration for a Unity project, specifying request parameters like email, profile, ID token, and auth code. It highlights the necessity of using the Web Client ID and optionally includes the Client Secret for editor testing.
```csharp
GoogleSignIn.Configuration = new GoogleSignInConfiguration() {
RequestEmail = true,
RequestProfile = true,
RequestIdToken = true,
RequestAuthCode = true,
// must be web client ID, not android client ID
WebClientId = "XXXXXXXXX-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com",
#if UNITY_EDITOR || UNITY_STANDALONE
ClientSecret = "XXXXXX-xxxXXXxxxXXXxxx-xxxxXXXXX" // optional for windows/macos and test in editor
#endif
};
```
--------------------------------
### Google Sign-In Configuration File Structure (JSON)
Source: https://github.com/thaina/google-signin-unity/blob/newmigration/README.md
This JSON structure represents the client-side configuration for Google Sign-In, specifically detailing OAuth client information. It's crucial for obtaining client IDs and package names required for authentication.
```json
{
"oauth_client": [
{
"client_id": "411000067631-hmh4e210xxxxxxxxxx373t3icpju8ooi.apps.googleusercontent.com",
"client_type": 3
},
{
"client_id": "411000067631-udra361txxxxxxxxxx561o9u9hc0java.apps.googleusercontent.com",
"client_type": 1,
"android_info": {
"package_name": "com.your.package.name.",
"certificate_hash": "7ada045cccccccccc677a38c91474628d6c55d03"
}
}
]
}
```
--------------------------------
### Configure Google Sign-In and Authenticate with Firebase
Source: https://github.com/thaina/google-signin-unity/blob/newmigration/README.md
This snippet demonstrates how to configure Google Sign-In to request an ID token and use it to authenticate with Firebase Auth. It handles the sign-in process and creates a Firebase credential from the obtained ID token.
```csharp
GoogleSignIn.Configuration = new GoogleSignInConfiguration {
RequestIdToken = true,
// Copy this value from the google-service.json file.
// oauth_client with type == 3
WebClientId = "1072123000000-iacvb7489h55760s3o2nf1xxxxxxxx.apps.googleusercontent.com"
};
Task signIn = GoogleSignIn.DefaultInstance.SignIn ();
TaskCompletionSource signInCompleted = new TaskCompletionSource ();
signIn.ContinueWith (task => {
if (task.IsCanceled) {
signInCompleted.SetCanceled ();
} else if (task.IsFaulted) {
signInCompleted.SetException (task.Exception);
} else {
Credential credential = Firebase.Auth.GoogleAuthProvider.GetCredential (((Task)task).Result.IdToken, null);
auth.SignInWithCredentialAsync (credential).ContinueWith (authTask => {
if (authTask.IsCanceled) {
signInCompleted.SetCanceled();
} else if (authTask.IsFaulted) {
signInCompleted.SetException(authTask.Exception);
} else {
signInCompleted.SetResult(((Task)authTask).Result);
}
});
}
});
```
--------------------------------
### Resolving Android Dependencies (Unity)
Source: https://github.com/thaina/google-signin-unity/blob/newmigration/README.md
This action within the Unity editor triggers the resolution of Google Play Services SDK dependencies for Android builds. It ensures that the necessary .aar files are correctly placed in the project's Assets/Plugins/Android directory.
```text
Assets/Play Services Resolver/Android Resolver/Resolve
```
--------------------------------
### Google Sign-In C# Implementation (Unity)
Source: https://github.com/thaina/google-signin-unity/blob/newmigration/GoogleSignIn/Editor/google-signin-plugin_v1.0.4.txt
Contains the core C# scripts for implementing Google Sign-In functionality within a Unity project. This includes user authentication, configuration, and handling of sign-in results.
```csharp
Assets/SignInSample/SigninSampleScript.cs
Assets/GoogleSignIn/Impl/GoogleSignInImpl.cs
Assets/GoogleSignIn/Impl/SignInHelperObject.cs
Assets/GoogleSignIn/Impl/NativeFuture.cs
Assets/GoogleSignIn/Impl/BaseObject.cs
Assets/GoogleSignIn/GoogleSignIn.cs
Assets/GoogleSignIn/GoogleSignInConfiguration.cs
Assets/GoogleSignIn/Future.cs
Assets/GoogleSignIn/GoogleSignInUser.cs
Assets/GoogleSignIn/GoogleSignInStatusCode.cs
```
--------------------------------
### Unity Compat and Tasks DLLs
Source: https://github.com/thaina/google-signin-unity/blob/newmigration/GoogleSignIn/Editor/google-signin-plugin_v1.0.4.txt
These DLLs, Unity.Compat.dll and Unity.Tasks.dll, are often used in Unity projects to provide compatibility features and task-based asynchronous operations, which may be leveraged by Google Sign-In or other plugins.
```plaintext
Assets/Parse/Plugins/Unity.Compat.dll
Assets/Parse/Plugins/Unity.Tasks.dll
```
--------------------------------
### Unity Dependency Management for Google Sign-In
Source: https://github.com/thaina/google-signin-unity/blob/newmigration/GoogleSignIn/Editor/google-signin-plugin_v1.0.4.txt
Editor scripts and XML configuration files used by Unity's Play Services Resolver to manage project dependencies for Google Sign-In, ensuring all required libraries are correctly included.
```xml
Assets/GoogleSignIn/Editor/GoogleSignInDependencies.xml
Assets/GoogleSignIn/Editor/GoogleSignInSupportDependencies.xml
```
--------------------------------
### Play Services Resolver DLLs (Unity)
Source: https://github.com/thaina/google-signin-unity/blob/newmigration/GoogleSignIn/Editor/google-signin-plugin_v1.0.4.txt
Contains DLL files for the Play Services Resolver, a Unity package that automatically handles dependencies for Google Play Services. These are essential for the correct functioning of Google-related services in Unity.
```plaintext
Assets/PlayServicesResolver/Editor/Google.VersionHandlerImpl_v1.2.89.0.dll
Assets/PlayServicesResolver/Editor/Google.IOSResolver_v1.2.89.0.dll
Assets/PlayServicesResolver/Editor/Google.VersionHandler.dll
Assets/PlayServicesResolver/Editor/Google.JarResolver_v1.2.89.0.dll
```
--------------------------------
### Handle Google Sign-In with Task Continuations in Unity
Source: https://context7.com/thaina/google-signin-unity/llms.txt
This C# code snippet demonstrates how to handle Google Sign-In using Task continuations in a Unity project. It allows for handling authentication results without async/await. The `OnAuthenticationFinished` method is executed after the sign-in task completes, handling potential errors or a successful sign-in.
```csharp
using Google;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
public class SignInSample : MonoBehaviour
{
public Text statusText;
private GoogleSignInConfiguration configuration;
void Awake()
{
configuration = new GoogleSignInConfiguration {
WebClientId = "123456789-abcdefghijklmnopqrstuvwxyz123456.apps.googleusercontent.com",
RequestIdToken = true,
RequestEmail = true,
RequestProfile = true
};
}
public void OnSignIn()
{
GoogleSignIn.Configuration = configuration;
statusText.text = "Signing in...";
GoogleSignIn.DefaultInstance.SignIn()
.ContinueWith(OnAuthenticationFinished, TaskScheduler.FromCurrentSynchronizationContext());
}
internal void OnAuthenticationFinished(Task task)
{
if (task.IsFaulted)
{
using (IEnumerator enumerator = task.Exception.InnerExceptions.GetEnumerator())
{
if (enumerator.MoveNext())
{
GoogleSignIn.SignInException error = (GoogleSignIn.SignInException)enumerator.Current;
statusText.text = $"Error: {error.Status} - {error.Message}";
Debug.LogError($"Sign-in failed: {error.Status}");
}
else
{
statusText.text = $"Unexpected exception: {task.Exception}";
}
}
}
else if (task.IsCanceled)
{
statusText.text = "Sign-in canceled by user";
Debug.Log("User canceled sign-in");
}
else
{
GoogleSignInUser user = task.Result;
statusText.text = $"Welcome {user.DisplayName}!";
Debug.Log($"Successfully signed in: {user.Email}");
Debug.Log($"User ID: {user.UserId}");
Debug.Log($"ID Token: {user.IdToken}");
}
}
}
```
--------------------------------
### Authenticate with Firebase using Google Sign-In in Unity (async/await)
Source: https://context7.com/thaina/google-signin-unity/llms.txt
This C# code snippet demonstrates how to authenticate a user with Firebase using Google Sign-In in a Unity project. It uses the Google Sign-In plugin and the Firebase Authentication SDK. The method `SignInWithGoogle` handles the authentication process using async/await.
```csharp
using Google;
using Firebase.Auth;
using System.Threading.Tasks;
using UnityEngine;
public class FirebaseGoogleAuth : MonoBehaviour
{
private FirebaseAuth auth;
private void Start()
{
auth = FirebaseAuth.DefaultInstance;
}
public async Task SignInWithGoogle()
{
// Configure Google Sign-In to request ID token
GoogleSignIn.Configuration = new GoogleSignInConfiguration {
RequestIdToken = true,
// Copy this value from google-services.json oauth_client with type == 3
WebClientId = "123456789-abcdefghijklmnopqrstuvwxyz123456.apps.googleusercontent.com"
};
try
{
// Perform Google Sign-In
GoogleSignInUser googleUser = await GoogleSignIn.DefaultInstance.SignIn();
Debug.Log($"Google sign-in successful: {googleUser.Email}");
// Create Firebase credential from Google ID token
Credential credential = GoogleAuthProvider.GetCredential(googleUser.IdToken, null);
// Sign in to Firebase with the credential
AuthResult authResult = await auth.SignInWithCredentialAsync(credential);
FirebaseUser firebaseUser = authResult.User;
Debug.Log($"Firebase authentication successful");
Debug.Log($"User ID: {firebaseUser.UserId}");
Debug.Log($"Display Name: {firebaseUser.DisplayName}");
Debug.Log($"Email: {firebaseUser.Email}");
return firebaseUser;
}
catch (GoogleSignIn.SignInException googleEx)
{
Debug.LogError($"Google Sign-In failed: {googleEx.Status} - {googleEx.Message}");
throw;
}
catch (System.Exception firebaseEx)
{
Debug.LogError($"Firebase authentication failed: {firebaseEx.Message}");
throw;
}
}
public async void OnGoogleSignInButtonClick()
{
try
{
FirebaseUser user = await SignInWithGoogle();
// Navigate to main game scene after successful authentication
UnityEngine.SceneManagement.SceneManager.LoadScene("MainGame");
}
catch (System.Exception ex)
{
Debug.LogError($"Authentication failed: {ex.Message}");
ShowErrorMessage("Failed to sign in. Please try again.");
}
}
private void ShowErrorMessage(string message)
{
// Display error to user
Debug.Log(message);
}
}
```
--------------------------------
### Google Sign-In iOS Native Implementation (Unity)
Source: https://github.com/thaina/google-signin-unity/blob/newmigration/GoogleSignIn/Editor/google-signin-plugin_v1.0.4.txt
Provides the native Objective-C++ code for handling Google Sign-In on iOS platforms within a Unity project. This is crucial for bridging native iOS functionalities to Unity.
```objectivec++
Assets/Plugins/iOS/GoogleSignIn/GoogleSignInAppController.mm
Assets/Plugins/iOS/GoogleSignIn/GoogleSignInAppController.h
Assets/Plugins/iOS/GoogleSignIn/GoogleSignIn.h
Assets/Plugins/iOS/GoogleSignIn/GoogleSignIn.mm
```
--------------------------------
### iOS PList Configuration for Google Credentials
Source: https://context7.com/thaina/google-signin-unity/llms.txt
XML formatted PList file for iOS applications, containing Google sign-in credentials. This file is automatically processed during the build process to configure the application with the correct client IDs.
```xml
CLIENT_ID
123456789-yyyyyYYYYyyyyYYYYYYYYYYYYYYyyyyyy.apps.googleusercontent.com
REVERSED_CLIENT_ID
com.googleusercontent.apps.123456789-yyyyyYYYYyyyyYYYYYYYYYYYYYYyyyyyy
PLIST_VERSION
1
BUNDLE_ID
com.yourcompany.yourproduct
WEB_CLIENT_ID
123456789-zzzZZZZZZZZZZZZZZzzzzzzzzzzZZZzzz.apps.googleusercontent.com
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.