Skip to content

Commit 2eca2a8

Browse files
committed
docs: windows custom protocols for redirects
1 parent 51ca794 commit 2eca2a8

File tree

1 file changed

+42
-2
lines changed
  • src/Packages/Passport/Runtime/Scripts/Public

1 file changed

+42
-2
lines changed

src/Packages/Passport/Runtime/Scripts/Public/Passport.cs

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ private Passport()
137137
/// </summary>
138138
/// <param name="clientId">The client ID</param>
139139
/// <param name="environment">The environment to connect to</param>
140-
/// <param name="redirectUri">The URL where the browser will redirect after successful authentication.</param>
141-
/// <param name="logoutRedirectUri">The URL where the browser will redirect after logout is complete.</param>
140+
/// <param name="redirectUri">The URL where the browser will redirect after successful authentication. On Windows, this must use a custom protocol (e.g., 'mygame://callback') instead of http/https.</param>
141+
/// <param name="logoutRedirectUri">The URL where the browser will redirect after logout is complete. On Windows, this must use a custom protocol (e.g., 'mygame://logout') instead of http/https.</param>
142142
/// <param name="engineStartupTimeoutMs">(Windows only) Timeout duration in milliseconds to wait for the default Windows browser engine to start.</param>
143143
/// <param name="windowsWebBrowserClient">(Windows only) Custom Windows browser to use instead of the default browser in the SDK.</param>
144144
public static UniTask<Passport> Init(
@@ -152,6 +152,10 @@ string logoutRedirectUri
152152
#endif
153153
)
154154
{
155+
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)
156+
ValidateWindowsProtocols(redirectUri, logoutRedirectUri);
157+
#endif
158+
155159
if (Instance == null)
156160
{
157161
PassportLogger.Info($"{TAG} Initialising Passport...");
@@ -681,5 +685,41 @@ private void DisposeAll()
681685
_deeplink = null;
682686
_readySignalReceived = false;
683687
}
688+
689+
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)
690+
/// <summary>
691+
/// Validates that custom protocols are used for Windows platforms instead of http/https.
692+
/// Windows uses registry-based deep linking which requires custom protocols.
693+
/// </summary>
694+
private static void ValidateWindowsProtocols(string redirectUri, string logoutRedirectUri)
695+
{
696+
if (IsHttpProtocol(redirectUri))
697+
{
698+
throw new PassportException(
699+
$"Invalid redirectUri for Windows: '{redirectUri}'. " +
700+
"Windows requires custom protocols (e.g., 'mygame://callback') instead of http/https. " +
701+
"This is because Windows uses registry-based deep linking that cannot redirect http/https URLs back to your game.",
702+
PassportErrorType.INITALISATION_ERROR);
703+
}
704+
705+
if (IsHttpProtocol(logoutRedirectUri))
706+
{
707+
throw new PassportException(
708+
$"Invalid logoutRedirectUri for Windows: '{logoutRedirectUri}'. " +
709+
"Windows requires custom protocols (e.g., 'mygame://logout') instead of http/https. " +
710+
"This is because Windows uses registry-based deep linking that cannot redirect http/https URLs back to your game.",
711+
PassportErrorType.INITALISATION_ERROR);
712+
}
713+
}
714+
715+
/// <summary>
716+
/// Checks if a URI uses http or https protocol.
717+
/// </summary>
718+
private static bool IsHttpProtocol(string uri)
719+
{
720+
return uri.StartsWith("http://", StringComparison.OrdinalIgnoreCase) ||
721+
uri.StartsWith("https://", StringComparison.OrdinalIgnoreCase);
722+
}
723+
#endif
684724
}
685725
}

0 commit comments

Comments
 (0)