diff --git a/sample/Assets/Scenes/Passport/SelectAuthMethod.unity b/sample/Assets/Scenes/Passport/SelectAuthMethod.unity index 018d37f27..17596d416 100644 --- a/sample/Assets/Scenes/Passport/SelectAuthMethod.unity +++ b/sample/Assets/Scenes/Passport/SelectAuthMethod.unity @@ -1866,21 +1866,20 @@ MonoBehaviour: 1. - Authorisation Code Flow with Proof Key for Code Exchange (PKCE) is available - for Android, iOS, macOS and WebGL (not officially supported). This method provides + Authorisation Code Flow with Proof Key for Code Exchange (PKCE): This method provides a seamless and secure authentication experience by opening a pop-up window on - macOS or an in-app browser on mobile devices. Players are automatically redirected + desktop or an in-app browser on mobile devices. Players are automatically redirected back to the game once authenticated, eliminating manual switching. 2. Device - Code Authorisation is available for Windows, Android, iOS and macOS. This method + Code Authorisation: This method opens the player''s default browser and guides them through the authentication flow. Recommendation: Whenever possible, use the PKCE flow as it is the - most secure and seamless method for authentication on Android, iOS and macOS.' + most secure and seamless method for authentication.' --- !u!222 &1688502351 CanvasRenderer: m_ObjectHideFlags: 0 diff --git a/sample/Assets/Scripts/Passport/PassportInitialisation/PassportInitialisationScript.cs b/sample/Assets/Scripts/Passport/PassportInitialisation/PassportInitialisationScript.cs index 6ce88edc1..7bf70927a 100644 --- a/sample/Assets/Scripts/Passport/PassportInitialisation/PassportInitialisationScript.cs +++ b/sample/Assets/Scripts/Passport/PassportInitialisation/PassportInitialisationScript.cs @@ -56,7 +56,7 @@ public void UsePKCE() /// /// Initialises Passport. /// - /// (Android, iOS and macOS only) The URL to which auth will redirect the browser after + /// The URL to which auth will redirect the browser after /// authorisation has been granted by the user /// The URL to which auth will redirect the browser /// after log out is complete diff --git a/sample/Assets/Scripts/Passport/_tutorials~/PassportInitialisation/tutorial.md b/sample/Assets/Scripts/Passport/_tutorials~/PassportInitialisation/tutorial.md index 286691d83..8b99bb4b6 100644 --- a/sample/Assets/Scripts/Passport/_tutorials~/PassportInitialisation/tutorial.md +++ b/sample/Assets/Scripts/Passport/_tutorials~/PassportInitialisation/tutorial.md @@ -75,7 +75,7 @@ For PKCE authentication, the redirect URIs must be configured correctly based on ### Prerequisites - Create an Immutable Hub account and get your client ID from [Immutable Hub](https://hub.immutable.com) - Set up the Unity project with the Immutable Passport SDK -- Configure your project for the appropriate platform (WebGL, Android, iOS, macOS, Windows) +- Configure your project for the appropriate platform ### Steps to Run the Example 1. Open the Unity project and load the sample scene for Passport Initialisation diff --git a/src/Packages/Passport/Runtime/Scripts/Private/Helpers/WindowsDeepLink.cs b/src/Packages/Passport/Runtime/Scripts/Private/Helpers/WindowsDeepLink.cs index 23cd8e823..bd810ad95 100644 --- a/src/Packages/Passport/Runtime/Scripts/Private/Helpers/WindowsDeepLink.cs +++ b/src/Packages/Passport/Runtime/Scripts/Private/Helpers/WindowsDeepLink.cs @@ -137,11 +137,12 @@ private static void CreateCommandScript(string protocolName) " powershell -NoProfile -ExecutionPolicy Bypass -Command ^", " \"$ErrorActionPreference = 'Continue';\" ^", " \"$wshell = New-Object -ComObject wscript.shell;\" ^", - " \"echo [$(Get-Date)] Attempting to activate process ID: %%A >> \\\"{logPath}\\\";\" ^", + " \"Add-Content -Path \\\"{logPath}\\\" -Value ('[' + (Get-Date) + '] Attempting to activate process ID: ' + %%A);\" ^", " \"Start-Sleep -Milliseconds 100;\" ^", " \"$result = $wshell.AppActivate(%%A);\" ^", - " \"echo [$(Get-Date)] AppActivate result: $result >> \\\"{logPath}\\\";\" ^", - " \"if (-not $result) { echo [$(Get-Date)] Failed to activate window >> \\\"{logPath}\\\" }\"", + " \"Add-Content -Path \\\"{logPath}\\\" -Value ('[' + (Get-Date) + '] AppActivate result: ' + $result);\" ^", + " \"if (-not $result) { Add-Content -Path \\\"{logPath}\\\" -Value ('[' + (Get-Date) + '] Failed to activate window') }\" ^", + " >nul 2>&1", " if errorlevel 1 echo [%date% %time%] PowerShell error: %errorlevel% >> \"%LOG_PATH%\"", " endlocal", " exit /b 0", @@ -213,8 +214,19 @@ private static void RegisterProtocol(string protocolName) throw new Exception($"Failed to create PKCE registry key. Error code: {result}"); } + // Set the default value for the protocol key to Application.productName + // This is often used by Windows as the display name for the protocol + string appProductName = Application.productName; + uint productNameDataSize = (uint)((appProductName.Length + 1) * Marshal.SystemDefaultCharSize); + int setDefaultResult = RegSetValueEx(hKey, null, 0, REG_SZ, appProductName, productNameDataSize); + + if (setDefaultResult != 0) + { + PassportLogger.Warn($"Failed to set default display name for protocol '{protocolName}'. Error code: {setDefaultResult}"); + } + // Set URL Protocol value - RegSetValueEx(hKey, "URL Protocol", 0, REG_SZ, string.Empty, 2); + RegSetValueEx(hKey, "URL Protocol", 0, REG_SZ, string.Empty, (uint)(1 * Marshal.SystemDefaultCharSize)); // Create command subkey UIntPtr commandKey; diff --git a/src/Packages/Passport/Runtime/Scripts/Public/Passport.cs b/src/Packages/Passport/Runtime/Scripts/Public/Passport.cs index a7419bcdf..1661f6fd8 100644 --- a/src/Packages/Passport/Runtime/Scripts/Public/Passport.cs +++ b/src/Packages/Passport/Runtime/Scripts/Public/Passport.cs @@ -137,7 +137,7 @@ private Passport() /// /// The client ID /// The environment to connect to - /// (Android, iOS, and macOS only) The URL where the browser will redirect after successful authentication. + /// The URL where the browser will redirect after successful authentication. /// The URL where the browser will redirect after logout is complete. /// (Windows only) Timeout duration in milliseconds to wait for the default Windows browser engine to start. /// (Windows only) Custom Windows browser to use instead of the default browser in the SDK. diff --git a/src/Packages/Passport/Samples~/SamplesScenesScripts/Scenes/Passport/SelectAuthMethod.unity b/src/Packages/Passport/Samples~/SamplesScenesScripts/Scenes/Passport/SelectAuthMethod.unity index 458e1dff9..b2687e60e 100644 --- a/src/Packages/Passport/Samples~/SamplesScenesScripts/Scenes/Passport/SelectAuthMethod.unity +++ b/src/Packages/Passport/Samples~/SamplesScenesScripts/Scenes/Passport/SelectAuthMethod.unity @@ -1822,15 +1822,14 @@ MonoBehaviour: 1. - Authorisation Code Flow with Proof Key for Code Exchange (PKCE) is available - for Android, iOS, macOS and WebGL (not officially supported). This method provides + Authorisation Code Flow with Proof Key for Code Exchange (PKCE): This method provides a seamless and secure authentication experience by opening a pop-up window on macOS or an in-app browser on mobile devices. Players are automatically redirected back to the game once authenticated, eliminating manual switching. 2. Device - Code Authorisation is available for Windows, Android, iOS and macOS. This method + Code Authorisation: This method opens the player''s default browser and guides them through the authentication flow. diff --git a/src/Packages/Passport/Samples~/SamplesScenesScripts/Scripts/Passport/SelectAuthMethodScript.cs b/src/Packages/Passport/Samples~/SamplesScenesScripts/Scripts/Passport/SelectAuthMethodScript.cs index 8fe8a8613..c4c94bbcd 100644 --- a/src/Packages/Passport/Samples~/SamplesScenesScripts/Scripts/Passport/SelectAuthMethodScript.cs +++ b/src/Packages/Passport/Samples~/SamplesScenesScripts/Scripts/Passport/SelectAuthMethodScript.cs @@ -56,7 +56,7 @@ public void UsePKCE() /// /// Initialises Passport. /// - /// (Android, iOS and macOS only) The URL to which auth will redirect the browser after + /// The URL to which auth will redirect the browser after /// authorisation has been granted by the user /// The URL to which auth will redirect the browser /// after log out is complete