I'm having trouble in setting up a multiple login profile for my website which is made in .Net 6.0 Core. What I'm trying to achieve is the following:
- Users logs to the website via Discord (this works and has been our overflow since now)
- In user edit page the user is prompt to login to Steam in order to gather the SteamID and save it with the other logged user's info.
The second task is what I'm not able to achieve, I've added the AspNet.Security.OpenId.Steam provider as did for the Discord (AspNet.Security.OAuth.Discord) but, once logged on Steam, while I receive the OpenID from Steam I lose track of who the user was before this interaction.
How can I implement the Steam login and save the ID without losing the Identity that the user had before access the Steam login page?
Startup.cs for Steam
.AddSteam("Steam", options =>
{
options.Events.OnTicketReceived = ctx =>
{
var steamID = ctx.Principal.FindFirstValue("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier");
// save steamID to user
return Task.CompletedTask;
};
})
I've tried the following instead of redirect via /Login:
public async Task<ActionResult> OnPostSaveSteamID()
{
var openid = new OpenIdRelyingParty();
var response = openid.GetResponse();
if (response != null)
{
switch (response.Status)
{
case AuthenticationStatus.Authenticated:
// do success
var responseURI = response.ClaimedIdentifier.ToString();
//"http://steamcommunity.com/openid/id/76561197969877387"
// last part is steam user id
break;
case AuthenticationStatus.Canceled:
case AuthenticationStatus.Failed:
// do fail
break;
}
}
else
{
using (OpenIdRelyingParty openidd = new OpenIdRelyingParty())
{
IAuthenticationRequest request = openidd.CreateRequest("http://steamcommunity.com/openid");
request.RedirectToProvider();
}
}
return Redirect("~/UserEdit");
}
But I get the following error at "var openid = new OpenIdRelyingParty();
Could not load type 'System.Web.HttpContext' from assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a