{"id":13664685,"url":"https://github.com/googlesamples/google-signin-unity","last_synced_at":"2025-04-13T11:48:20.716Z","repository":{"id":43580238,"uuid":"106719334","full_name":"googlesamples/google-signin-unity","owner":"googlesamples","description":"Google Sign-In API plugin for Unity game engine.  Works with Android and iOS.","archived":false,"fork":false,"pushed_at":"2024-08-19T16:44:06.000Z","size":235,"stargazers_count":439,"open_issues_count":197,"forks_count":252,"subscribers_count":23,"default_branch":"master","last_synced_at":"2025-04-04T05:09:03.287Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/googlesamples.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-10-12T16:40:40.000Z","updated_at":"2025-04-03T16:52:45.000Z","dependencies_parsed_at":"2024-01-07T06:00:42.415Z","dependency_job_id":"1592448c-1bd5-4d91-b689-8494e64a774b","html_url":"https://github.com/googlesamples/google-signin-unity","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/googlesamples%2Fgoogle-signin-unity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/googlesamples%2Fgoogle-signin-unity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/googlesamples%2Fgoogle-signin-unity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/googlesamples%2Fgoogle-signin-unity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/googlesamples","download_url":"https://codeload.github.com/googlesamples/google-signin-unity/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248710411,"owners_count":21149186,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T05:03:04.016Z","updated_at":"2025-04-13T11:48:20.683Z","avatar_url":"https://github.com/googlesamples.png","language":"C++","funding_links":[],"categories":["C++"],"sub_categories":[],"readme":"# Google Sign-In Unity Plugin\n_Copyright (c) 2017 Google Inc. All rights reserved._\n\n\n## Overview\n\nGoogle Sign-In API plugin for Unity game engine.  Works with Android and iOS.\nThis plugin exposes the Google Sign-In API within Unity.  This is specifically\nintended to be used by Unity projects that require OAuth ID tokens or server\nauth codes.\n\nIt is cross-platform, supporting both Android and iOS.\n\nSee [Google Sign-In for Android](https://developers.google.com/identity/sign-in/android/start)\nfor more information.\n\n## Configuring the application  on the API Console\n\nTo authenticate you need to create credentials on the API console for your\napplication. The steps to do this are available on\n[Google Sign-In for Android](https://developers.google.com/identity/sign-in/android/start)\nor as part of Firebase configuration.\nIn order to access ID tokens or server auth codes, you also need to configure\na web client ID.\n\n## How to build the sample\n\n\n### Get a Google Sign-In configuration file\nThis file contains the client-side information needed to use Google Sign-in.\nThe details on how to do this are documented on the [Developer website](https://developers.google.com/identity/sign-in/android/start-integrating#get-config).\n\nOnce you have the configuration file, open it in a text editor.  In the middle\nof the file you should see the __oauth_client__ section:\n```\n      \"oauth_client\": [\n        {\n          \"client_id\": \"411000067631-hmh4e210xxxxxxxxxx373t3icpju8ooi.apps.googleusercontent.com\",\n          \"client_type\": 3\n        },\n        {\n          \"client_id\": \"411000067631-udra361txxxxxxxxxx561o9u9hc0java.apps.googleusercontent.com\",\n          \"client_type\": 1,\n          \"android_info\": {\n            \"package_name\": \"com.your.package.name.\",\n            \"certificate_hash\": \"7ada045cccccccccc677a38c91474628d6c55d03\"\n          }\n        }\n      ]\n```\n\nThere are 3 values you need for configuring your Unity project:\n1. The __Web client ID__.  This is needed for generating a server auth code for\nyour backend server, or for generating an ID token.  This is the `client_id`\nvalue for the oauth client with client_type == 3.\n2. The __package_name__.  The client entry with client_type == 1 is the\nAndroid client.  The package_name must be entered in the Unity player settings.\n3.  The keystore used to sign your application. This is configured in the publishing settings of the Android Player properties in\nthe Unity editor.  This must be the same keystore used to generate\nthe SHA1 fingerprint when creating the application on the console.  __NOTE:__\nThe configutation file does not reference the keystore, you need to keep track of\nthis yourself.\n\n\n### Create a new project and import the plugin\nCreate a new Unity project and import the `GoogleSignIn-1.0.0.unitypackage` (or the latest version).\nThis contains native code, C# Unity code needed to call the Google Sign-In API for both Android and iOS.\n\n### Import the sample scene\nImport the `GoogleSignIn-sample.unitypackage` which contains the sample scene and\nscripts.  This package is not needed if you are integrating Google Sign-in into\nyour own application.\n\n### Configure the web client id\n1. Open the sample scene in `Assets/SignInSample/MainScene`.\n2. Select the Canvas object in the hierarchy and enter the web client id\nin the __SignInSampleScript__ component.\n\n## Building for Android\n1. Under Build Settings, select Android as the target platform.\n2. Set the package name in the player settings to the package_name you found in\nthe configuration file.\n3. Select the keystore file, the key alias, and passwords.\n4. Resolve the Google Play Services SDK dependencies by selecting from the menu:\n    __Assets/Play Services Resolver/Android Resolver/Resolve__.  This will add\n    the required .aar files to your project in `Assets/Plugins/Android`.\n\n## Building for iOS\nFor iOS, follow the instructions for creating a GoogleService-Info.plist file on\nhttps://developers.google.com/identity/sign-in/ios/start-integrating.\n\nIn Unity, after switching to the iOS player, make sure to run the Play Services\nResolver.  This will add the required frameworks and libraries to the XCode\nproject via CocoPods.\n\nAfter generating the XCode project from Unity, download the GoogleService-Info.plist file\nfrom the Google Developers website and add it to your XCode project.\n\n## Using the Games Profile to sign in on Android\nTo use the Play Games Services Gamer profile when signing in, you need to edit the\ndependencies in `Assets/GoogleSignIn/Editor/GoogleSignInDependencies.xml`.\n\nUncomment the play-services-games dependency and re-run the resolution.\n\n\n## Using this plugin with Firebase Auth\nFollow the instructions to use Firebase Auth with Credentials on the [Firebase developer website]( https://firebase.google.com/docs/unity/setup).\n\nMake sure to copy the google-services.json and/or GoogleService-Info.plist to your Unity project.\n\nThen to use Google SignIn with Firebase Auth, you need to request an ID token when authenticating.\nThe steps are:\n1. Configure Google SignIn to request an id token and set the web client id as described above.\n2. Call __SignIn()__ (or __SignInSilently()__).\n3. When handling the response, use the ID token to create a Firebase Credential.\n4. Call Firebase Auth method  __SignInWithCredential()__.\n\n```\n    GoogleSignIn.Configuration = new GoogleSignInConfiguration {\n      RequestIdToken = true,\n      // Copy this value from the google-service.json file.\n      // oauth_client with type == 3\n      WebClientId = \"1072123000000-iacvb7489h55760s3o2nf1xxxxxxxx.apps.googleusercontent.com\"\n    };\n\n    Task\u003cGoogleSignInUser\u003e signIn = GoogleSignIn.DefaultInstance.SignIn ();\n\n    TaskCompletionSource\u003cFirebaseUser\u003e signInCompleted = new TaskCompletionSource\u003cFirebaseUser\u003e ();\n    signIn.ContinueWith (task =\u003e {\n      if (task.IsCanceled) {\n        signInCompleted.SetCanceled ();\n      } else if (task.IsFaulted) {\n        signInCompleted.SetException (task.Exception);\n      } else {\n\n        Credential credential = Firebase.Auth.GoogleAuthProvider.GetCredential (((Task\u003cGoogleSignInUser\u003e)task).Result.IdToken, null);\n        auth.SignInWithCredentialAsync (credential).ContinueWith (authTask =\u003e {\n          if (authTask.IsCanceled) {\n            signInCompleted.SetCanceled();\n          } else if (authTask.IsFaulted) {\n            signInCompleted.SetException(authTask.Exception);\n          } else {\n            signInCompleted.SetResult(((Task\u003cFirebaseUser\u003e)authTask).Result);\n          }\n        });\n      }\n    });\n```\n\n\n## Building the Plugin\nTo build the plugin run `./gradlew -PlintAbortOnError build_all`. This builds the support aar\nlibrary with lint warnings as errors and packages the plugin into a .unitypackage file.  It\nalso packages the sample scene and script in a separate package.\n\nThere's also a shortcut for linux/mac: `./build_all`.\n\n\n## Questions? Problems?\nPost questions to this [Github project](https://github.com/googlesamples/google-signin-unity).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgooglesamples%2Fgoogle-signin-unity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgooglesamples%2Fgoogle-signin-unity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgooglesamples%2Fgoogle-signin-unity/lists"}