ASP.NET网站的Steam身份验证

时间:2018-09-25 14:05:25

标签: c# asp.net-mvc asp.net-web-api steam steam-web-api

您能谈谈我如何通过Asp.Net Web API C#在我的网站上通过Steam进行授权吗?我发现这仅适用于php。一些代码用于桌面,但Web api不使用。我没有任何代码。我想使用c#进行Steam OpenId身份验证。它是使用php https://github.com/SmItH197/SteamAuthentication的Steam auth,但我需要使用C#。我找到了一些代码,但是此代码适用于台式机应用程序(据我所知)

protected void Page_Load(object sender, EventArgs e)
 {
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();
    }
}

}

如何在网站上使用它?

0 个答案:

没有答案