﻿
{"id":12941,"date":"2019-12-30T22:43:38","date_gmt":"2019-12-30T22:43:38","guid":{"rendered":"https:\/\/www.gencayyildiz.com\/blog\/?p=12941"},"modified":"2019-12-30T22:58:38","modified_gmt":"2019-12-30T22:58:38","slug":"asp-net-core-identity-google-login","status":"publish","type":"post","link":"https:\/\/www.gencayyildiz.com\/blog\/asp-net-core-identity-google-login\/","title":{"rendered":"Asp.NET Core Identity \u2013 Google Login"},"content":{"rendered":"<div id=\"fb-root\"><\/div>\n<p>Merhaba,<\/p>\n<p>Bir \u00f6nceki <a href=\"https:\/\/www.gencayyildiz.com\/blog\/asp-net-core-identity-facebook-login\/\" target=\"_blank\" rel=\"noopener noreferrer\">Asp.NET Core Identity \u2013 Facebook Login<\/a> ba\u015fl\u0131kl\u0131 makalemizde Asp.NET Core Identity mimarisi ile Facebook \u00fczerinden login i\u015flemlerinin nas\u0131l yap\u0131ld\u0131\u011f\u0131n\u0131 ele alm\u0131\u015ft\u0131k. Bu i\u00e7eri\u011fimizde ise yine benzer mahiyette ilgili mimari ile Google login i\u015flemlerini ele alaca\u011f\u0131z&#8230;<\/p>\n<p>Her\u015feyden \u00f6nce \u015funu bilmenizi isterim ki, Asp.NET Core Identity mimarisinde &#8220;\u00dc\u00e7\u00fcnc\u00fc Taraf Kimlik Do\u011frulama&#8221; yap\u0131lanmalar\u0131 t\u00fcm sosyal a\u011flar i\u00e7in birebir ayn\u0131 olmak kayd\u0131yla ge\u00e7erlidir. Yani Google login yapabilmek i\u00e7in Facebook, Twitter vs. loginler de ne yapt\u0131ysak birebir ayn\u0131s\u0131n\u0131 yapmam\u0131z gerekmektedir.<\/p>\n<p>Bu sebepten dolay\u0131 ben bu ve bundan sonraki t\u00fcm \u00fc\u00e7\u00fcnc\u00fc taraf kimlik do\u011frulama makalelerimde yukar\u0131da adresini verdi\u011fim Facebook login makalesinde olu\u015fturdu\u011fum proje \u00fczerinden anlat\u0131m sergileyece\u011fim. Neticede genel \u00e7at\u0131yla birlikte temeli anlamland\u0131rd\u0131\u011f\u0131n\u0131z taktirde istedi\u011finiz herhangi bir sa\u011flay\u0131c\u0131 taraf\u0131ndan kimlik do\u011frulama \u00f6zelli\u011fini uygulaman\u0131za kazand\u0131rman\u0131z\u0131n ne kadar basit oldu\u011funa sizde \u015fahit olacaks\u0131n\u0131z.<\/p>\n<h3>Google Developer\u2019dan Uygulama Yap\u0131land\u0131rma<\/h3>\n<p>\u0130lk olarak t\u00fcm sa\u011flay\u0131c\u0131larda oldu\u011fu gibi kar\u015f\u0131 tarafta uygulamam\u0131z\u0131 temsil edecek bir proje yap\u0131land\u0131rmam\u0131z gerekmektedir. Bunun i\u00e7in <a href=\"https:\/\/developers.google.com\/identity\/sign-in\/web\/sign-in#before_you_begin\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/developers.google.com\/identity\/sign-in\/web\/sign-in#before_you_begin<\/a> adresine t\u0131klayarak uygulaman\u0131za Google Authentication \u00f6zelli\u011fini entegre edecek bir yap\u0131land\u0131rmada bulunabilirsiniz.<\/p>\n<p>\u0130lgili ba\u011flant\u0131ya t\u0131klad\u0131ktan sonra a\u00e7\u0131lan sayfa \u00fczerinden a\u015fa\u011f\u0131daki \u00f6nergeleri ad\u0131m ad\u0131m uygulay\u0131n\u0131z;<\/p>\n<ul>\n<li><strong>Ad\u0131m 1<\/strong><br \/>\nA\u00e7\u0131lan sayfada bulunan &#8216;<em>Configure a project<\/em>&#8216; butonuna t\u0131klayarak a\u00e7\u0131lan pencerede uygulama ad\u0131n\u0131 belirttikten sonra &#8216;<em>Next<\/em>&#8216; butonuna t\u0131klay\u0131n\u0131z.<br \/>\n<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-12954\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login.png\" alt=\"Asp.NET Core Identity \u2013 Google Login\" width=\"744\" height=\"583\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login.png 744w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-300x235.png 300w\" sizes=\"auto, (max-width: 744px) 100vw, 744px\" \/><\/a><\/li>\n<li><strong>Ad\u0131m 2<\/strong><br \/>\nBir \u00fcr\u00fcn ismi belirleyiniz ve &#8216;<em>Next<\/em>&#8216; butonuna t\u0131klay\u0131n\u0131z.<br \/>\n<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-12957\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-1.png\" alt=\"Asp.NET Core Identity \u2013 Google Login\" width=\"374\" height=\"100\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-1.png 374w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-1-300x80.png 300w\" sizes=\"auto, (max-width: 374px) 100vw, 374px\" \/><\/a><\/li>\n<li><strong>Ad\u0131m 3<\/strong><br \/>\nS\u0131radaki pencerede &#8216;<em>Where are you calling from?<\/em>&#8216; yazan alanda &#8216;<em>Web Browser<\/em>&#8216; sekmesini se\u00e7iniz ve ard\u0131ndan a\u015fa\u011f\u0131s\u0131nda \u00e7al\u0131\u015fma yap\u0131lan uygulaman\u0131n adresini belirledikten sonra &#8216;<em>Create<\/em>&#8216; butonuna t\u0131klay\u0131n\u0131z.<br \/>\n<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-12959\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-2.png\" alt=\"Asp.NET Core Identity \u2013 Google Login\" width=\"585\" height=\"266\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-2.png 585w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-2-300x136.png 300w\" sizes=\"auto, (max-width: 585px) 100vw, 585px\" \/><\/a><\/li>\n<li id=\"ad\u0131m4\"><strong>Ad\u0131m 4<\/strong><br \/>\nNihai olarak kar\u015f\u0131n\u0131za &#8220;Client ID&#8221; ve &#8220;Client Secret&#8221; de\u011ferlerini bar\u0131nd\u0131ran a\u015fa\u011f\u0131daki pencere gelecektir.<br \/>\n<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-12963\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-3.png\" alt=\"Asp.NET Core Identity \u2013 Google Login\" width=\"573\" height=\"376\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-3.png 573w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-3-300x197.png 300w\" sizes=\"auto, (max-width: 573px) 100vw, 573px\" \/><\/a><br \/>\nHer ne kadar bizlere laz\u0131m olan bu veriler elde edilmi\u015f olsada daha i\u015fimiz bitmedi \ud83d\ude42 5. ad\u0131mdan devam ediniz&#8230; \ud83d\ude42<\/li>\n<li><strong>Ad\u0131m 5<\/strong><br \/>\nGoogle \u00fcr\u00fcn\u00fcn\u00fc olu\u015fturduktan sonra <a href=\"https:\/\/console.cloud.google.com\/\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/console.cloud.google.com\/<\/a> adresine giriniz ve soldaki men\u00fcden &#8216;<em>API&#8217;ler ve Hizmetler<\/em>&#8216; kategorisine gelerek &#8216;<em>Kitapl\u0131k<\/em>&#8216; sekmesine t\u0131klay\u0131n\u0131z.<br \/>\n<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-12964\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-4.png\" alt=\"Asp.NET Core Identity \u2013 Google Login\" width=\"477\" height=\"278\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-4.png 477w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-4-300x175.png 300w\" sizes=\"auto, (max-width: 477px) 100vw, 477px\" \/><\/a><\/li>\n<li><strong>Ad\u0131m 6<\/strong><br \/>\nA\u00e7\u0131lan pencerede arama \u00e7ubu\u011funa &#8220;Google+&#8221; yaz\u0131n\u0131z ve gelen sonu\u00e7lar aras\u0131ndan &#8216;<em>Google+ API<\/em>&#8216; k\u00fct\u00fcphanesini Google projenizde etkinle\u015ftiriniz.<br \/>\n<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-5.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-12966\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-5.png\" alt=\"Asp.NET Core Identity \u2013 Google Login\" width=\"825\" height=\"429\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-5.png 825w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-5-300x156.png 300w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-5-768x399.png 768w\" sizes=\"auto, (max-width: 825px) 100vw, 825px\" \/><\/a><br \/>\n<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-6.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-12968\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-6.png\" alt=\"Asp.NET Core Identity \u2013 Google Login\" width=\"696\" height=\"290\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-6.png 696w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-6-300x125.png 300w\" sizes=\"auto, (max-width: 696px) 100vw, 696px\" \/><\/a><\/li>\n<li><strong>Ad\u0131m 7<\/strong><br \/>\n<em>Google+ API<\/em> k\u00fct\u00fcphanesini aktifle\u015ftirdikten sonra s\u0131rada bu uygulamaya ait kimlik bilgileri olu\u015fturmaya gelmi\u015ftir. Bunun i\u00e7in soldaki men\u00fc \u00fczerinden &#8216;<em>API&#8217;ler ve Hizmetler<\/em>&#8216; kategorisine gelerek bu sefer &#8216;<em>Kontrol Paneli<\/em>&#8216; sekmesine giriniz.<br \/>\n<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-7.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-12970\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-7.png\" alt=\"Asp.NET Core Identity \u2013 Google Login\" width=\"409\" height=\"259\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-7.png 409w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-7-300x190.png 300w\" sizes=\"auto, (max-width: 409px) 100vw, 409px\" \/><\/a><\/li>\n<li><strong>Ad\u0131m 8<\/strong><br \/>\nA\u00e7\u0131lan pencerede a\u015fa\u011f\u0131daki listede bulunan <em>Google+ API<\/em> k\u00fct\u00fcphanesine t\u0131klay\u0131n\u0131z.<br \/>\n<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-8.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-12973\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-8.png\" alt=\"Asp.NET Core Identity \u2013 Google Login\" width=\"558\" height=\"634\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-8.png 558w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-8-264x300.png 264w\" sizes=\"auto, (max-width: 558px) 100vw, 558px\" \/><\/a><\/li>\n<li><strong>Ad\u0131m 9<\/strong><br \/>\nVe ard\u0131ndan sa\u011f \u00fcst k\u00f6\u015fedeki &#8216;<em>Kimlik Bilgileri Olu\u015ftur<\/em>&#8216; sekmesine t\u0131klay\u0131n\u0131z.<br \/>\n<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-9.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-12975\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-9.png\" alt=\"Asp.NET Core Identity \u2013 Google Login\" width=\"1190\" height=\"175\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-9.png 1190w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-9-300x44.png 300w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-9-1024x151.png 1024w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-9-768x113.png 768w\" sizes=\"auto, (max-width: 1190px) 100vw, 1190px\" \/><\/a><\/li>\n<li><strong>Ad\u0131m 10<\/strong><br \/>\nA\u00e7\u0131lan sayfada &#8216;Google+ API&#8217; se\u00e7iniz ve ard\u0131ndan &#8216;<em>Hangi kimlik bilgilerine ihtiyac\u0131m var?<\/em>&#8216; butonuna t\u0131klay\u0131n\u0131z.<br \/>\n<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-10.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-12978\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-10.png\" alt=\"Asp.NET Core Identity \u2013 Google Login\" width=\"584\" height=\"258\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-10.png 584w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-10-300x133.png 300w\" sizes=\"auto, (max-width: 584px) 100vw, 584px\" \/><\/a><\/li>\n<li><strong>Ad\u0131m 11<\/strong><br \/>\nKimlik bilgilerinin olu\u015fturuldu\u011funu g\u00f6rd\u00fckten sonra &#8216;<em>Bitti<\/em>&#8216; butonuna t\u0131klay\u0131n\u0131z.<br \/>\n<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-11.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-12983\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-11.png\" alt=\"Asp.NET Core Identity \u2013 Google Login\" width=\"497\" height=\"349\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-11.png 497w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-11-300x211.png 300w\" sizes=\"auto, (max-width: 497px) 100vw, 497px\" \/><\/a><\/li>\n<li><strong>Ad\u0131m 12<\/strong><br \/>\n\u015eimdi s\u0131ra OAuth istemci kimli\u011fi olu\u015fturmaya geldi. Bunun i\u00e7in yine &#8216;<em>API&#8217;ler ve Hizmetler<\/em>&#8216; kategorisindeki &#8216;<em>Kimlik bilgileri<\/em>&#8216; sekmesi \u00fczerinden &#8216;<em>Kimlik bilgilerini olu\u015ftur<\/em>&#8216; men\u00fcs\u00fc alt\u0131ndaki &#8216;<em>OAuth istemci kimli\u011fi<\/em>&#8216; sekmesini a\u00e7\u0131n\u0131z.<br \/>\n<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-12.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-12985\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-12.png\" alt=\"Asp.NET Core Identity \u2013 Google Login\" width=\"706\" height=\"250\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-12.png 706w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-12-300x106.png 300w\" sizes=\"auto, (max-width: 706px) 100vw, 706px\" \/><\/a><\/li>\n<li><strong>Ad\u0131m 13<\/strong><br \/>\nA\u00e7\u0131lan pencerede a\u015fa\u011f\u0131daki ekran g\u00f6r\u00fcnt\u00fcs\u00fcnde de oldu\u011fu gibi uygulama t\u00fcr\u00fcn\u00fc &#8216;<em>Web uygulamas\u0131<\/em>&#8216; olarak se\u00e7iniz, yetkilendirilmi\u015f sayfa olarak web uygulama adresinizi belirtiniz ve geri d\u00f6n\u00fc\u015f yolunuda Identity mimarisinin Google API i\u00e7in varsay\u0131lan olarak belirledi\u011fi &#8220;<em>signin-google<\/em>&#8221; \u015feklinde belirtiniz.<br \/>\n<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-13.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-12991\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-13.png\" alt=\"Asp.NET Core Identity \u2013 Google Login\" width=\"463\" height=\"783\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-13.png 463w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-13-177x300.png 177w\" sizes=\"auto, (max-width: 463px) 100vw, 463px\" \/><\/a><\/li>\n<li><strong>Ad\u0131m 14<\/strong><br \/>\nT\u00fcm bu i\u015flemler neticesinde, nihai olarak uygulamaya dair a\u015fa\u011f\u0131daki gibi &#8220;Client ID&#8221; ve &#8220;Client Secret Key&#8221; bilgileri edinilmi\u015f olacakt\u0131r.<br \/>\n<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-14.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-12995\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-14.png\" alt=\"Asp.NET Core Identity \u2013 Google Login\" width=\"493\" height=\"338\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-14.png 493w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login-14-300x206.png 300w\" sizes=\"auto, (max-width: 493px) 100vw, 493px\" \/><\/a><br \/>\n<a href=\"#ad\u0131m4\" rel=\"noopener\">Ad\u0131m 4<\/a>&#8216;te elde etti\u011fimiz id ve secret keyler yerine bizim esas\u0131nda bu de\u011ferleri kullanaca\u011f\u0131m\u0131z\u0131 bilmenizi isterim.\u015eimdi yapmam\u0131z gereken i\u015flem projemize sa\u011f t\u0131klayarak &#8216;<em>Manage User Secrets<\/em>&#8216; sekmesi \u00fczerinden <em>secrets.json<\/em> dosyas\u0131n\u0131 a\u00e7arak bu elde edilen verileri oraya eklemektir.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n{\r\n  &quot;FacebookAppId&quot;: &quot;464106821187753&quot;,\r\n  &quot;FacebookAppSecret&quot;: &quot;eb9e2bbeab7a28ee97cbdbc20935ed97&quot;,\r\n  &quot;GoogleClientId&quot;: &quot;711179820585-85gbprstal7kqra3aph8vp1ir7bombm9.apps.googleusercontent.com&quot;,\r\n  &quot;GoogleClientSecret&quot;: &quot;QTddNtWLxBrqGV1hXsgZRKGg&quot;\r\n}\r\n<\/pre>\n<p>Makalemizin ba\u015f\u0131nda da bahsetti\u011fim gibi bir \u00f6nceki Facebook login ile ilgili makale \u00fczerinden \u00f6rneklendirme yap\u0131yor oldu\u011fumuzdan dolay\u0131 ilgili dosya i\u00e7erisinde Google uygulamas\u0131n\u0131n d\u0131\u015f\u0131nda da di\u011fer uygulamalara dair kodlar\u0131n bulunmas\u0131 olduk\u00e7a do\u011fald\u0131r&#8230;<\/li>\n<\/ul>\n<p>T\u00fcm ad\u0131mlar\u0131 tamamlad\u0131ktan sonra art\u0131k Google uygulamas\u0131 olu\u015fturulmu\u015f ve login i\u015flemleri i\u00e7in hali haz\u0131r hale getirilmi\u015f bulunmaktad\u0131r.<\/p>\n<p>\u015eimdi ilk olarak yapman\u0131z gereken Google authentication yap\u0131lanmas\u0131n\u0131 kullanabilmek i\u00e7in <a href=\"https:\/\/www.nuget.org\/packages\/Microsoft.AspNetCore.Authentication.Google\" target=\"_blank\" rel=\"noopener noreferrer\">Microsoft.AspNetCore.Authentication.Google<\/a> k\u00fct\u00fcphanesini projenize y\u00fckleyiniz.<\/p>\n<p>Ard\u0131ndan &#8220;Startup&#8221; dosyas\u0131ndaki &#8220;ConfigureServices&#8221; metodu i\u00e7erisinde a\u015fa\u011f\u0131daki \u00e7al\u0131\u015fmay\u0131 ger\u00e7ekle\u015ftiriniz.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n    public class Startup\r\n    {\r\n        public IConfiguration Configuration { get; set; }\r\n        .\r\n        .\r\n        .\r\n        public void ConfigureServices(IServiceCollection services)\r\n        {\r\n            .\r\n            .\r\n            .\r\n\r\n            services.AddAuthentication()\r\n                .AddFacebook(x =&gt;\r\n                {\r\n                    x.AppId = Configuration&#x5B;&quot;FacebookAppId&quot;];\r\n                    x.AppSecret = Configuration&#x5B;&quot;FacebookAppSecret&quot;];\r\n                    x.CallbackPath = new PathString(&quot;\/User\/Hata&quot;);\r\n                })\r\n                .AddGoogle(x =&gt;\r\n                {\r\n                    x.ClientId = Configuration&#x5B;&quot;GoogleClientId&quot;];\r\n                    x.ClientSecret = Configuration&#x5B;&quot;GoogleClientSecret&quot;];\r\n                });\r\n\r\n            .\r\n            .\r\n        }\r\n    }\r\n<\/pre>\n<p>Yukar\u0131daki kod blo\u011funda 20 ile 24. sat\u0131rlar aras\u0131na g\u00f6z atarsan\u0131z e\u011fer &#8220;AddGoogle&#8221; fonksiyonu ile uygulamam\u0131za Google Authentication eklenmi\u015ftir. B\u00f6ylece ilgili uygulamada Facebook oldu\u011fu gibi Google login i\u015flemide ger\u00e7ekle\u015ftirilebilir vaziyettedir.<\/p>\n<p>S\u0131rada Google login talebinin sorumlulu\u011funu \u00fcstlenecek olan action metodun geli\u015ftirilmesi vard\u0131r. Bunun i\u00e7in &#8220;User(Controller).cs&#8221; dosyas\u0131nda &#8220;GoogleLogin&#8221; isimli bir action olu\u015fturunuz ve i\u00e7eri\u011fini a\u015fa\u011f\u0131daki gibi doldurunuz.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n        public IActionResult GoogleLogin(string ReturnUrl)\r\n        {\r\n            string redirectUrl = Url.Action(&quot;ExternalResponse&quot;, &quot;User&quot;, new { ReturnUrl = ReturnUrl });\r\n            \/\/Google'a yap\u0131lan Login talebi neticesinde kullan\u0131c\u0131y\u0131 y\u00f6nlendirmesini istedi\u011fimiz url'i olu\u015fturuyoruz.\r\n            AuthenticationProperties properties = _signInManager.ConfigureExternalAuthenticationProperties(&quot;Google&quot;, redirectUrl);\r\n            \/\/Ba\u011flant\u0131 kurulacak harici platformun hangisi oldu\u011funu belirtiyor ve ba\u011flant\u0131 \u00f6zelliklerini elde ediyoruz.\r\n            return new ChallengeResult(&quot;Google&quot;, properties);\r\n            \/\/ChallengeResult; kimlik do\u011frulamak i\u00e7in gerekli olan t\u00fcm \u00f6zellikleri kapsayan AuthenticationProperties nesnesini al\u0131r ve ayarlar.\r\n        }\r\n<\/pre>\n<p>Yukar\u0131daki kod blo\u011funa g\u00f6z atarsan\u0131z e\u011fer 5. sat\u0131rdaki hangi platforma login talebinde bulunuldu\u011funu belirtti\u011fimiz &#8220;ConfigureExternalAuthenticationProperties&#8221; metodunun birinci parametresine verilen &#8220;Google&#8221; de\u011ferinin birebir ayn\u0131 olmas\u0131 gerekti\u011fine \u00f6zen g\u00f6steriniz.<\/p>\n<p>Bu i\u015flemden sonra art\u0131k son olarak Google login talebi neticesinde d\u00f6nen sonucun i\u015flenmesi ve gerekli giri\u015f yahut kay\u0131t i\u015flemlerinin yap\u0131lmas\u0131 gerekmektedir. Bunun i\u00e7in yukar\u0131daki &#8220;GoogleLogin&#8221; metodunda olu\u015fturdu\u011fumuz redirect url&#8217;de ki &#8220;ExternalResponse&#8221; isimli metodunu a\u015fa\u011f\u0131daki gibi in\u015fa ediniz.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n        public async Task&lt;IActionResult&gt; ExternalResponse(string ReturnUrl = &quot;\/&quot;)\r\n        {\r\n            ExternalLoginInfo loginInfo = await _signInManager.GetExternalLoginInfoAsync();\r\n            \/\/Kullan\u0131c\u0131yla ilgili d\u0131\u015f kaynaktan gelen t\u00fcm bilgileri ta\u015f\u0131yan nesnedir.\r\n            \/\/Bu nesnesnin 'LoginProvider' propertysinin de\u011ferine g\u00f6z atarsan\u0131z e\u011fer hangi d\u0131\u015f kaynaktan geliniyorsa onun bilgisinin yazd\u0131\u011f\u0131n\u0131 g\u00f6receksiniz.\r\n            if (loginInfo == null)\r\n                return RedirectToAction(&quot;Login&quot;);\r\n            else\r\n            {\r\n                Microsoft.AspNetCore.Identity.SignInResult loginResult = await _signInManager.ExternalLoginSignInAsync(loginInfo.LoginProvider, loginInfo.ProviderKey, true);\r\n                \/\/Giri\u015f yap\u0131yoruz.\r\n                if (loginResult.Succeeded)\r\n                    return Redirect(ReturnUrl);\r\n                else\r\n                {\r\n                    \/\/E\u011fer ki ak\u0131\u015f bu blo\u011fa girerse ilgili kullan\u0131c\u0131 uygulamam\u0131za kay\u0131t olmad\u0131\u011f\u0131ndan dolay\u0131 giri\u015fi ba\u015far\u0131s\u0131z demektir.\r\n                    \/\/O halde kay\u0131t i\u015flemini yap\u0131p, ard\u0131ndan giri\u015f yapt\u0131rmam\u0131z gerekmektedir.\r\n                    AppUser user = new AppUser\r\n                    {\r\n                        Email = loginInfo.Principal.FindFirst(ClaimTypes.Email).Value,\r\n                        UserName = loginInfo.Principal.FindFirst(ClaimTypes.Email).Value\r\n                    };\r\n                    \/\/D\u0131\u015f kaynaktan gelen Claimleri uygun e\u015flendikleri propertylere at\u0131yoruz.\r\n                    IdentityResult createResult = await _userManager.CreateAsync(user);\r\n                    \/\/Kullan\u0131c\u0131 kayd\u0131n\u0131 yap\u0131yoruz.\r\n                    if (createResult.Succeeded)\r\n                    {\r\n                        \/\/E\u011fer kay\u0131t ba\u015far\u0131l\u0131ysa ilgili kullan\u0131c\u0131 bilgilerini AspNetUserLogins tablosuna kaydetmemiz gerekmektedir ki\r\n                        \/\/bir sonraki d\u0131\u015f kaynak login talebinde Identity mimarisi ilgili kullan\u0131c\u0131n\u0131n hangi d\u0131\u015f kaynaktan geldi\u011fini anlayabilsin.\r\n                        IdentityResult addLoginResult = await _userManager.AddLoginAsync(user, loginInfo);\r\n                        \/\/Kullan\u0131c\u0131 bilgileri d\u0131\u015f kaynaktan gelen bilgileriyle AspNetUserLogins tablosunda e\u015fle\u015ftirilmek suretiyle kaydedilmi\u015ftir.\r\n                        if (addLoginResult.Succeeded)\r\n                        {\r\n                            await _signInManager.SignInAsync(user, true);\r\n                            \/\/await _signInManager.ExternalLoginSignInAsync(loginInfo.LoginProvider, loginInfo.ProviderKey, true);\r\n                            return Redirect(ReturnUrl);\r\n                        }\r\n                    }\r\n\r\n                }\r\n            }\r\n            return Redirect(ReturnUrl);\r\n        }\r\n<\/pre>\n<h3>Derleme, \u00c7al\u0131\u015ft\u0131rma, Test Etme<\/h3>\n<p>\u015eimdi s\u0131ra geli\u015ftirilen uygulamay\u0131 test etmeye gelmi\u015ftir. Bunun i\u00e7in uygulamay\u0131 derleyip, \u00e7al\u0131\u015ft\u0131rd\u0131\u011f\u0131n\u0131z vakit a\u015fa\u011f\u0131daki ekran g\u00f6r\u00fcnt\u00fcs\u00fcnde oldu\u011fu gibi Google login yap\u0131lanmas\u0131n\u0131 test etti\u011finiz taktirde kusursuz \u00e7al\u0131\u015ft\u0131\u011f\u0131n\u0131 g\u00f6rebilirsiniz.<br \/>\n<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login.gif\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-13011\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/Asp.NET-Core-Identity-\u2013-Google-Login.gif\" alt=\"Asp.NET Core Identity \u2013 Google Login\" width=\"800\" height=\"453\" \/><\/a><\/p>\n<p>\u0130lgilenenlerin faydalanmas\u0131 dile\u011fiyle&#8230;<br \/>\nSonraki yaz\u0131lar\u0131mda g\u00f6r\u00fc\u015fmek \u00fczere&#8230;<br \/>\n\u0130yi \u00e7al\u0131\u015fmalar&#8230;<\/p>\n<p>Not : \u00d6rnek \u00e7al\u0131\u015fma projesini indirebilmek i\u00e7in <a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/12\/GoogleLoginExample.zip\">buraya<\/a> t\u0131klay\u0131n\u0131z.<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>Merhaba, Bir \u00f6nceki Asp.NET Core Identity \u2013 Facebook Login ba\u015fl\u0131kl\u0131 makalemizde Asp.NET Core Identity mimarisi ile Facebook \u00fczerinden login i\u015flemlerinin nas\u0131l yap\u0131ld\u0131\u011f\u0131n\u0131 ele alm\u0131\u015ft\u0131k. Bu i\u00e7eri\u011fimizde ise yine benzer mahiyette ilgili mimari ile Google&#46;&#46;&#46;<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":12942,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3102,2668,2656,2811,2832,2898,3103],"tags":[3110,2952,3106,3107,3109,3108],"class_list":["post-12941","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-asp-net-core","category-asp-net-core-2","category-asp-net-core-2-mvc","category-asp-net-core-2-1","category-asp-net-core-2-2","category-asp-net-core-3-0","category-asp-net-core-3-1","tag-asp-net-core-google","tag-asp-net-core-identity","tag-asp-net-core-identity-google-login","tag-google-login","tag-identity-google","tag-identity-google-login"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/12941","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/comments?post=12941"}],"version-history":[{"count":54,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/12941\/revisions"}],"predecessor-version":[{"id":13017,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/12941\/revisions\/13017"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/media\/12942"}],"wp:attachment":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/media?parent=12941"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/categories?post=12941"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/tags?post=12941"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}