Skip to content

Commit 8f0e87f

Browse files
committed
EcosystemWallet.GenerateExternalLoginLink
1 parent 9d58235 commit 8f0e87f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Thirdweb/Thirdweb.Wallets/InAppWallet/EcosystemWallet/EcosystemWallet.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,21 @@ public async Task<EcosystemDetails> GetEcosystemDetails()
312312
return JsonConvert.DeserializeObject<EcosystemDetails>(content);
313313
}
314314

315+
public string GenerateExternalLoginLink(string redirectUrl)
316+
{
317+
var authProvider = HttpUtility.UrlEncode(this.AuthProvider.ToLower());
318+
var walletId = this.GetType().Name.Contains("InAppWallet") ? "inApp" : this._ecosystemId;
319+
var authCookie = HttpUtility.UrlEncode(this.EmbeddedWallet.GetSessionData()?.AuthToken ?? "");
320+
321+
if (string.IsNullOrEmpty(authCookie))
322+
{
323+
throw new InvalidOperationException("Cannot generate external login link without an active session.");
324+
}
325+
326+
var queryString = redirectUrl.Contains('?') ? "&" : "?" + $"walletId={walletId}&authProvider={authProvider}&authCookie={authCookie}";
327+
return $"{redirectUrl}{queryString}";
328+
}
329+
315330
#endregion
316331

317332
#region Account Linking

0 commit comments

Comments
 (0)