This article describes for you how to use the Google OpenID Authentication using DotNetOpenAuth in ASP.Net.Download the DotNetOpenAuth from here. First of all make a new website and add a reference to DotNetOpenAuth.dll.Drag and drop a button on page.<asp:Button ID="btnLoginToGoogle" Runat="server" Text="Google Login" OnCommand="OpenLogin_Click" CommandArgument="https://www.google.com/accounts/o8/id" Font-Bold="True" Font-Italic="True" Width="162px" />
using DotNetOpenAuth.OpenId;using DotNetOpenAuth.OpenId.RelyingParty; protected void Page_Load(object sender, EventArgs e) { OpenIdRelyingParty OIDRP = new OpenIdRelyingParty(); var str = OIDRP.GetResponse(); if (str != null) { switch (str.Status) { case AuthenticationStatus.Authenticated: NotLoggedIn.Visible = false; Session["GoogleIdentifier"] = str.ClaimedIdentifier.ToString(); Response.Redirect("Home.aspx"); break; case AuthenticationStatus.Canceled: lblMessage.Text = "Cancelled."; break; case AuthenticationStatus.Failed: lblMessage.Text = "Login Failed."; break; } } } protected void OpenLogin_Click(object src, CommandEventArgs e) { string str = e.CommandArgument.ToString(); OpenIdRelyingParty openid = new OpenIdRelyingParty(); var b = new UriBuilder(Request.Url) { Query = "" }; var req = openid.CreateRequest(str, b.Uri, b.Uri); req.RedirectToProvider(); } Now run the website. Image 1When you click on Login button.Image2.Insert google email and password. Image3.
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: