asp.net Webforms谷歌登录 [英] asp.net webforms google login

查看:64
本文介绍了asp.net Webforms谷歌登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在网上寻找一种解决方案,以便在asp.net网络表单应用程序上使用用户的Google帐户进行身份验证.

I have been searching the net for a solution to use a users google account for authentications on a asp.net webform application.

我想要的是用户登录到他的Google帐户,然后使用显示名称,google ID和电子邮件表单返回我的Webform应用程序,其余的工作将由我负责.

All I want is that the user login to his google account and return to my webform application with display name, google ID and Email form there I will take care of the rest.

我已经尝试过 http://dotnetopenauth.net/,Google .Net Api,但我从未找到有效的示例

I have tried http://dotnetopenauth.net/, Google .Net Api but I never found a working example.

任何人都可以通过一个有效的例子向我指出正确的方向.(C#或vb.net)

Can anybody point me in the right direction with a example that works. (C# or vb.net)

推荐答案

您是否考虑过提供 Nemiro.OAuth 尝试一下?它很容易设置,支持asp.net和winforms,并且在线文档非常详细.

Have you thought about giving Nemiro.OAuth a try? It's easy to set up, supports asp.net and winforms, and the online documentation is very detailed.

protected void RedirectToLogin_Click(object sender, EventArgs e)
{
  // gets a provider name from the data-provider
  string provider = ((LinkButton)sender).Attributes["data-provider"];
  // build the return address
  string returnUrl = new Uri(Request.Url, "ExternalLoginResult.aspx").AbsoluteUri;
  // redirect user into external site for authorization
  OAuthWeb.RedirectToAuthorization(provider, returnUrl);
}

protected void Page_Load(object sender, EventArgs e)
{
   var result = OAuthWeb.VerifyAuthorization();

   Response.Write(String.Format("Provider: {0}<br />", result.ProviderName));

   if (result.IsSuccessfully)
   {
      // successfully
      var user = result.UserInfo;
      Response.Write(String.Format("User ID:  {0}<br />", user.UserId));
      Response.Write(String.Format("Name:     {0}<br />", user.DisplayName));
      Response.Write(String.Format("Email:    {0}", user.Email));
    }
    else
    {
      // error
      Response.Write(result.ErrorInfo.Message);
    }
 }

您还可以遵循本教程逐步说明如何将OAuth与Nemiro.OAuth库一起使用.

You can also follow this tutorial for a step-by-step instruction on how to use OAuth with Nemiro.OAuth library.

这篇关于asp.net Webforms谷歌登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆