{"id":18242664,"url":"https://github.com/mestackcodes/signinwithgoogledelphi","last_synced_at":"2025-07-19T00:37:49.050Z","repository":{"id":260900586,"uuid":"881548886","full_name":"MEStackCodes/SignInWithGoogleDelphi","owner":"MEStackCodes","description":"Delphi component for integrating Google Sign-In using the Android Credential Manager","archived":false,"fork":false,"pushed_at":"2025-01-26T14:11:14.000Z","size":86946,"stargazers_count":9,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-11T15:00:36.480Z","etag":null,"topics":["android","androidx","credential-manager","credentials","delphi","delphi-components","firemonkey","google","google-sign-in","java","jni","kotlin","pascal-language"],"latest_commit_sha":null,"homepage":"","language":"Pascal","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MEStackCodes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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,"zenodo":null}},"created_at":"2024-10-31T19:39:34.000Z","updated_at":"2025-01-28T00:50:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"b2ff1143-2982-4604-be7b-9d328bb89cf8","html_url":"https://github.com/MEStackCodes/SignInWithGoogleDelphi","commit_stats":null,"previous_names":["mestackcodes/signinwithgoogledelphi"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MEStackCodes/SignInWithGoogleDelphi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MEStackCodes%2FSignInWithGoogleDelphi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MEStackCodes%2FSignInWithGoogleDelphi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MEStackCodes%2FSignInWithGoogleDelphi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MEStackCodes%2FSignInWithGoogleDelphi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MEStackCodes","download_url":"https://codeload.github.com/MEStackCodes/SignInWithGoogleDelphi/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MEStackCodes%2FSignInWithGoogleDelphi/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265863793,"owners_count":23840888,"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":["android","androidx","credential-manager","credentials","delphi","delphi-components","firemonkey","google","google-sign-in","java","jni","kotlin","pascal-language"],"created_at":"2024-11-05T07:07:25.329Z","updated_at":"2025-07-19T00:37:49.031Z","avatar_url":"https://github.com/MEStackCodes.png","language":"Pascal","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Platform](https://img.shields.io/badge/Android-3DDC84?style=flat-square\u0026logo=android\u0026logoColor=white)\n![Delphi](https://img.shields.io/badge/Delphi%2012.x-CC342D?style=flat-square\u0026logo=delphi\u0026logoColor=white)\n\n# Google Sign-In with Credential Manager for Delphi/FMX/Android\n\n**TSignInWithGoogle** is a straightforward library/component that enables Google Sign-in using Android's Credential Manager in a Object Pascal/Delphi environment, adhering to Google's most recent guidelines.\n\n\u003cimg src=\"./Resources/imagedemo.png\" width=\"100%\" alt=\"SignIn Demo\"\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n \n## Requirements\n\n- `Delphi Athens +12x`\n- `Binary (JAR/AAR) Dependencies`\n- `Android SDK API Level +33`\n- `Set up your Google Identity APIs console project` - [API Console](https://console.cloud.google.com/apis) \n\n## Installing\n\n- Add the **TSignInWithGoogle** folder path to your project in the menu: `Project-\u003e Options-\u003e Delphi Compiler-\u003e Search Path`.\n- Add all *.jar files located inside the **JAR-dependencies** folder to your project. From the right side panel: `Target Platforms -\u003e Android -\u003e Libraries`. Right click and select Add..\n\n\n## Usage - Code Examples\n\n1. Add the `SignInWithGoogle` unit to your project's uses clause:\n\n    ```pascal\n    uses\n      SignInWithGoogle;\n    ```\n\n2. Create an instance of `TSignInWithGoogle` and assign the events:\n\n    ```pascal\n    var\n    SignInWithGoogle: TSignInWithGoogle;\n\n    SignInWithGoogle := TSignInWithGoogle.Create(Self);\n      with SignInWithGoogle do\n       begin\n        SetGoogleClientID('xxxxxxxxx-xxxxxx.apps.googleusercontent.com');  \n        OnClearStateCredentialSuccessfully:= Self.OnClearStateCredentialSuccessfully;\n        OnClearStateCredentialException := Self.OnClearStateCredentialException;      \n        OnSignInException := Self.OnSignInException;\n        OnSignInSuccessfully := Self.OnSignInSuccessfully;    \n       end;\n    ```\n\n3. Get Credential (Classic Modal UI) for SignInWithGoogle Button\n\n    ```pascal\n    with SignInWithGoogle do\n    begin        \n      BuildSignInWithGoogleButton;\n      GetCredential;\n    end;\n    ```\n\n 4. Or Get Credential (Credential Manager's bottom sheet UI)\n\n    ```pascal\n    with SignInWithGoogle do\n    begin        \n      BuildSignInGoogleOptions(False, False)\n      GetCredential;\n    end;\n    ```  \n\n 5. Clear Credential State\n\n    ```pascal\n    with SignInWithGoogle do\n    begin              \n     ClearCredentialState; \n    end;\n    ```  \n\n\n## Methods\n- `SetGoogleClientID(ClientID: String)`: (Required): Sets the Google Client ID obtained from the credentials manager in the Google Console. You can download it as a JSON file in the configuration. Make sure it's the identifier type 3 (Web) and not type 1 (Android).  More details can be found \u003ca href=\"https://developer.android.com/identity/sign-in/credential-manager-siwg#sign-in\" target=\"_blank\"\u003ehere\u003c/a\u003e \n\n- `SetNonce(hashNonce: String)`:  Assigns the provided string as a Nonce identifier. If not called, an automatic Nonce hash will be created.\n\n- `GetNonce: String`: Retrieves the automatically generated Nonce hash. If the nonce was provided by the user, it returns the same string.\n\n- `BuildSignInWithGoogleButton`:  Generates options for calling the SignInWithGoogle button (modal UI).\n\n- `BuildSignInGoogleOptions(setFilterByAuthorizedAccounts: Boolean; setAutoSelectEnabled: Boolean)`: Generates options for the bottom DataSheet. Parameters:\n    - `setFilterByAuthorizedAccounts`:  Displays authorized Google accounts if set to `True`.\n    - `setAutoSelectEnabled`: Enables automatic login.\n    More details can be found \u003ca href=\"https://developer.android.com/identity/sign-in/credential-manager-siwg#sign-in\" target=\"_blank\"\u003ehere\u003c/a\u003e\n\n- `GetCredential`:  Calls the credentials window (asynchronous).\n\n- `ClearCredentialState`: Clears the stored credential state (asynchronous).\n\n- `EnabledDebugging(Flag: Boolean)`: (for debugging purposes): Activates debug messages visible in LogCat or other log viewers.\n\n\n## Events\n\n- `OnSignInSuccessfully`: Triggered when the user successfully signs in.\n- `OnSignInException`: Handles exceptions during the sign-in process.\n- `OnClearStateCredentialSuccessfully`: Fired when the credential state is cleared successfully.\n- `OnClearStateCredentialException`: Handles exceptions when clearing the credential state.\n ##\n- `OnSignInSuccessfully = procedure (Sender: TObject; Result: TSignInResult)`: Receives a record with user login information.\n- `OnSignInException = procedure (Sender: TObject; Error: Exception; Status: TSignInErrorStatus)`: Receives an `Exception` object and a status.\n- `OnClearStateCredentialSuccesfully = procedure (Sender: TObject;)`: it does not receive parameters.\n- `OnClearStateCredentialException = procedure (Sender: TObject; Error: Exception)`: Receives an `Exception` object.\n\n\n## AndroidManifest.template.xml\n\nMake sure this line identifying the Google Play service is present in your manifest. Delphi does not always add this metadata tag. \n```xml\n\u003cmeta-data android:name=\"com.google.android.gms.version\" android:value=\"12451000\" /\u003e\n ```\n\nJust below the `\u003c%uses-libraries%\u003e` add this tag block to activate the Credential Provider Meta Service:\n```xml\n\u003c%uses-libraries%\u003e\n \u003cservice android:name=\"androidx.credentials.playservices.CredentialProviderMetadataHolder\"\n  android:enabled=\"true\"\n  android:exported=\"false\"\u003e\n \u003cmeta-data  \n  android:name=\"androidx.credentials.CREDENTIAL_PROVIDER_KEY\"\n  android:value=\"androidx.credentials.playservices.CredentialProviderPlayServicesImpl\"/\u003e\n \u003c/service\u003e\n```\n\nAlso below the above block another tag block should be added to start the Google UI activity.\n```xml\n \u003cactivity\n  android:name=\"androidx.credentials.playservices.HiddenActivity\"\n  android:configChanges=\"orientation|keyboardHidden|screenSize|screenLayout\"\n  android:enabled=\"true\"\n  android:exported=\"false\"\n  android:resizeableActivity=\"true\"            \n  android:theme=\"@style/SignInUITheme\"\n  android:fitsSystemWindows=\"true\"\u003e            \n  \u003c/activity\u003e\n```\n\nThe following tag blocks can be bypassed by placing `android:theme=\"@style/SignInUITheme\"` --\u003e `android:theme=\"@null\"` but you may experience visual issues and window scrolling when launching the Google UI in your app on FMX. \n\nFrom `Project-\u003e Deployment` you can manage the location of these files for Debug and Release.\n\nAdd the following to your project's `styles-v31.xml` file:\n```xml\n\u003cresources xmlns:android=\"http://schemas.android.com/apk/res/android\"\u003e\n    \n    \u003c!-- Default Delphi Resource --\u003e\n    \u003cstyle name=\"AppTheme\" parent=\"@android:style/Theme.Material.Light.NoActionBar\"\u003e\n        \u003citem name=\"android:windowBackground\"\u003e@color/splash_background\u003c/item\u003e\n        \u003citem name=\"android:windowClipToOutline\"\u003efalse\u003c/item\u003e       \n        \u003c!-- API 31+ specific attributes --\u003e\n        \u003citem name=\"android:windowSplashScreenBackground\"\u003e@color/splash_background\u003c/item\u003e\n        \u003citem name=\"android:windowSplashScreenAnimatedIcon\"\u003e@drawable/splash_vector\u003c/item\u003e\n        \u003citem name=\"android:windowSplashScreenIconBackgroundColor\"\u003e@color/splash_background\u003c/item\u003e\n    \u003c/style\u003e\n\n\u003c!-- You just have to copy this part --\u003e\n\u003cstyle name=\"SignInUITheme\" parent=\"@android:style/Theme.Material.Light.NoActionBar\"\u003e\n    \u003citem name=\"android:windowIsTranslucent\"\u003etrue\u003c/item\u003e\n    \u003citem name=\"android:windowBackground\"\u003e@android:color/transparent\u003c/item\u003e\n    \u003citem name=\"android:windowContentOverlay\"\u003e@null\u003c/item\u003e\n    \u003citem name=\"android:windowNoTitle\"\u003etrue\u003c/item\u003e\n    \u003citem name=\"android:windowIsFloating\"\u003efalse\u003c/item\u003e\n    \u003citem name=\"android:backgroundDimEnabled\"\u003etrue\u003c/item\u003e\n    \u003citem name=\"android:windowTranslucentStatus\"\u003etrue\u003c/item\u003e\n    \u003citem name=\"android:windowTranslucentNavigation\"\u003etrue\u003c/item\u003e\n\u003c/style\u003e\n\u003c!-- You just have to copy this part --\u003e\n\n\u003c/resources\u003e\n```\n\nNow add the following to your project's `styles-v21.xml` file:\n```xml\n\u003cresources xmlns:android=\"http://schemas.android.com/apk/res/android\"\u003e\n\n    \u003c!-- Default Delphi Resource --\u003e\n    \u003cstyle name=\"AppTheme\" parent=\"@android:style/Theme.Material.Light.NoActionBar\"\u003e\n        \u003citem name=\"android:windowBackground\"\u003e@drawable/splash_image_def\u003c/item\u003e\n        \u003citem name=\"android:windowClipToOutline\"\u003efalse\u003c/item\u003e\n    \u003c/style\u003e\n   \n   \u003c!-- You just have to copy this part --\u003e\n   \u003cstyle name=\"SignInUITheme\" parent=\"@android:style/Theme.Material.Light.NoActionBar\"\u003e\n    \u003citem name=\"android:windowIsTranslucent\"\u003etrue\u003c/item\u003e\n    \u003citem name=\"android:windowBackground\"\u003e@android:color/transparent\u003c/item\u003e\n    \u003citem name=\"android:windowContentOverlay\"\u003e@null\u003c/item\u003e\n    \u003citem name=\"android:windowNoTitle\"\u003etrue\u003c/item\u003e\n    \u003citem name=\"android:windowIsFloating\"\u003efalse\u003c/item\u003e\n    \u003citem name=\"android:backgroundDimEnabled\"\u003etrue\u003c/item\u003e\n    \u003citem name=\"android:windowTranslucentStatus\"\u003etrue\u003c/item\u003e\n    \u003citem name=\"android:windowTranslucentNavigation\"\u003etrue\u003c/item\u003e\n \u003c/style\u003e\n \u003c!-- You just have to copy this part --\u003e\n\u003c/resources\u003e\n```\n\n## Known Issues\n - The `OnSignInException` event always fires, with the message: *\"the activity was canceled by the user\"*, this is an issue related to setting up credentials in the Google console. Verify that the client ID is type 3 and that your application's SHA-1 signing is configured correctly in your account. Additionally, OAuth consent screen page must be configured correctly for use.\n\n- The `OnSignInException` event fires with the message: *\"failed to launch the selector UI, Hint: ensure the 'context' parameter is an activity-based context\"*. This error appears if a valid activity is not defined to start the credentials window. Make sure you add the hidden activity block for Google UI in your manifest file as described above. \n\n- The `OnSignInException` event fires with the message: *\"GetCredentialAsync no provider dependencies found - please ensure the desired provider dependencies are added.*\" Make sure you add the service provider credentials in your manifest file and also the dependencies of the jar/aar files in your project.\n\n## Share\nIf you liked and found this repository useful for your projects, star it. Thank you for your support! ⭐\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmestackcodes%2Fsigninwithgoogledelphi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmestackcodes%2Fsigninwithgoogledelphi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmestackcodes%2Fsigninwithgoogledelphi/lists"}