Asp.net Gmail İle Login Olmak
SanalData’yı Google’da tercih edilen kaynak olarak ekleyinMerhabalar,
Asp.net ‘de gmail yani google hesabınızı kullanarak üye girişi veya login alanı yapmak isterseniz. Burdan direk örnek kodu indirebilirsiniz.Kodlaması ise aşağıdaki gibidir.
Html
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CS.aspx.cs" Inherits="CS2" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <style type="text/css"> body { font-family: Arial; font-size: 10pt; } </style> </head> <body> <form id="form1" runat="server"> <div> <asp:Button ID="btnLogin" Text="Login" runat="server" OnClick="Login" /> <asp:Panel ID="pnlProfile" runat="server" Visible="false"> <hr /> <table> <tr> <td rowspan="6" valign="top"> <asp:Image ID="ProfileImage" runat="server" Width="50" Height="50" /> </td> </tr> <tr> <td> ID: <asp:Label ID="lblId" runat="server" Text=""></asp:Label> </td> </tr> <tr> <td> Name: <asp:Label ID="lblName" runat="server" Text=""></asp:Label> </td> </tr> <tr> <td> Email: <asp:Label ID="lblEmail" runat="server" Text=""></asp:Label> </td> </tr> <tr> <td> Verified Email: <asp:Label ID="lblVerified" runat="server" Text=""></asp:Label> </td> </tr> <tr> <td> <asp:Button Text="Clear" runat="server" OnClick="Clear" /> </td> </tr> </table> </asp:Panel> </div> </form> </body> </html> |
Codebehind tarafı
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Text; using System.Net; using System.IO; using ASPSnippets.GoogleAPI; using System.Web.Script.Serialization; public partial class CS2 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { GoogleConnect.ClientId = "<Google Client ID>"; GoogleConnect.ClientSecret = "<Google Client Secret>"; GoogleConnect.RedirectUri = Request.Url.AbsoluteUri.Split('?')[0]; if (!this.IsPostBack) { if (!string.IsNullOrEmpty(Request.QueryString["code"])) { string code = Request.QueryString["code"]; string json = GoogleConnect.Fetch("me", code); GoogleProfile profile = new JavaScriptSerializer().Deserialize<GoogleProfile>(json); lblId.Text = profile.Id; lblName.Text = profile.Name; lblEmail.Text = profile.Email; lblVerified.Text = profile.Verified_Email; ProfileImage.ImageUrl = profile.Picture; pnlProfile.Visible = true; btnLogin.Enabled = false; } if (Request.QueryString["error"] == "access_denied") { ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "alert('Access denied.')", true); } } } protected void Login(object sender, EventArgs e) { GoogleConnect.Authorize("profile", "email"); } protected void Clear(object sender, EventArgs e) { GoogleConnect.Clear(Request.QueryString["code"]); } public class GoogleProfile { public string Id { get; set; } public string Name { get; set; } public string Picture { get; set; } public string Email { get; set; } public string Verified_Email { get; set; } } } |
Bir sonraki konuda görüşünceye kadar bol sorgulu günler 🙂
Günün zaman çizelgesi
Haber eklenme saatine göre sıralanır.
- Bugün
- Telefon Çekmiyorsa Deneyebileceğiniz Çözümler
- IPTV Nedir? Yasal Yayınlarla Kaçak Servis Arasındaki Fark
- Windows 11 Çalıştır penceresi yenileniyor: Gözat yok
- Apple TV 4K’da 8 GB RAM var, uygulama sınırı 2 GB
- Gemini Docs ve Sheets dosyalarını sohbet içinde düzenliyor
- The Witcher 4 için 2028 çıkış iddiası yeniden gündemde
- Dün
- Akıllı gözlükler mahkeme, okul ve havuzlarda yasaklanıyor
- Expert RAW, Galaxy S27 ile 30 kare DNG çekebilecek
- Fuelio, Android Auto’da yakıt fiyatlarını karşılaştırıyor
- COMAC’ın elektrikli uçağı CE-25A mürettebatla uçtu
- Cloudflare, yapay zekâ ajanları için Kitesurf’ü açtı
- BMW M 1000 RS tanıtıldı: 215 beygir, 196 kg
- GTA 6’nın hikâyesi 50 saat, platin kupası 200 saat sürebilir
- SİPER Ürün-2’nin menzili 150 kilometreyi aşıyor