ExternalLoginCallback action in asp net core

Поділитися
Вставка
  • Опубліковано 11 січ 2025

КОМЕНТАРІ •

  • @fahedabdelhalim3019
    @fahedabdelhalim3019 5 років тому +2

    Thank you .. great video
    Best teacher ever seen kudvenkat

    • @piasuddin3846
      @piasuddin3846 5 років тому

      I think in the whole world there is no anyone like Venkat sir...

  • @Fr3dii
    @Fr3dii 3 роки тому

    Great tutorial. Really helped break down the concept of external login for me. Thanks Kudvenkat

  • @iliesbenhaddouche2970
    @iliesbenhaddouche2970 5 років тому +6

    Awesome explanation as usual. To ensure continuity I hope you plan to make tutorial on azure. Thank you for your continued effort.

  • @loveunimeanit
    @loveunimeanit 5 років тому

    You are great ... thanks as always ...

  • @javaguitarist
    @javaguitarist 4 роки тому +1

    At 7:33, how can ClaimTypes.Email possibly return both the UserName and the Email properties? Shouldn't it be something like ClaimTypes.UserName for the UserName?
    user = new ApplicationUser{UserName = info.Principal.FindFirstValue(ClaimTypes.Email),
    Email = info.Principal.FindFirstValue(ClaimTypes.Email)};

    • @conaxlearn8566
      @conaxlearn8566 4 роки тому +2

      Remember for locally registered users, we have been using email address as the value for both email and username.

  • @vladkorsak2163
    @vladkorsak2163 4 роки тому

    Thank u bro. It's really helped me.

  • @suatsuphi
    @suatsuphi 3 роки тому

    thanks kudvenkat, I have problem with hashtag ? how to remove it and why I get it ? you have same problem in your video time: 12:36

  • @aleksandrzhadetsky2535
    @aleksandrzhadetsky2535 4 роки тому

    helpful video, thank you!

  • @Vagelis_Prokopiou
    @Vagelis_Prokopiou 5 років тому

    Thanks for the video 👍

  • @mohamedashash27
    @mohamedashash27 3 роки тому

    I'm wondering if i want to change the view page after we signed in what code i will change?
    example : after login we go to Account/Index , how change it to another controll like Accountsettings/change
    , etc

  • @davidgates5189
    @davidgates5189 3 роки тому

    you are living legend I am considering tattooing your name, watching other people explaining this is so painful comparing to you.

  • @ByMyKolaps
    @ByMyKolaps 3 роки тому

    Thank you, man!

  • @muhammadwaqasiqbal8243
    @muhammadwaqasiqbal8243 4 роки тому

    Hi Sir Venkat!
    I tried to login using an account which i hadnt registered and i was expecting it will show the error messages we have assigned to viewbag but instead it thew an exception! my question is when are we going to see the error messages of claim types we have assigned to viewbag.

  • @conaxlearn8566
    @conaxlearn8566 4 роки тому

    Question 1: So when the first sign in attempt failed by calling ExternalLoginSignInAsync(), we do a bunch of stuff. Then when we retry sign in, why are we calling SignInAsync() instead of calling ExternalLoginSignInAsync() again?
    Question 2: Theoretically if GetExternalLoginInfoAsync() returns the info with the user's email address, all we need to do is to try and find the user by calling FindByEmailAsync(). If FindByEmailAsync() doesn't return the user then we call CreateAsync(). After that, we can call SignInAsync() to sign in the user. All this without the need of using ExternalLoginSignInAsync() and the AspNetUserLogins table. So why can't we do it this way? (I have test coded this way to prove that it works.)

    • @sahiltiwari3518
      @sahiltiwari3518 3 роки тому

      Hi @Conax learn I am getting the error as insert statement casing conflict with primary key constraints

    • @sahiltiwari3518
      @sahiltiwari3518 3 роки тому

      Is there any solution

    • @sahiltiwari3518
      @sahiltiwari3518 3 роки тому

      Hi Team got the resolution . Solution is working fine . Many thanks . I was doing some mistakes and now realised

  • @mohammedaljohani7792
    @mohammedaljohani7792 5 років тому

    Venkat, could you kindly explain why this line (var info = await signInManager.GetExternalLoginInfoAsync();) return null , when I use AzureAD login :(

  • @LT-yk7xy
    @LT-yk7xy 2 роки тому

    Hey Venkat, what if we don’t use identity and depend entirely on external authentication..?? Can we still use call back??

  • @thesuperiorman8342
    @thesuperiorman8342 5 років тому

    Did kudvenkat discard the employee entity and replace it with an identity use? Can someone clarify please. I'm confused.

  • @nishanthmohan
    @nishanthmohan 4 роки тому

    Why the Manage menu is showing for external new user sign in ? External user doesn't have any roles..right ?

  • @daophilac
    @daophilac 4 роки тому

    I have a question Venkat!
    In what situation we don't receive email from the provider?

  • @khalilaibrahim1278
    @khalilaibrahim1278 5 років тому

    Thank you very much Venkat, could you kindly explain why this line (var info = await signInManager.GetExternalLoginInfoAsync();) return null , when I use AzureAD login

    • @mostafaanssary6135
      @mostafaanssary6135 4 роки тому

      try to check ConfigureExternalAuthenticationProperties and what you pass to it some time when you pass not valid parameter GetExternalLoginInfoAsync fail

  • @senolkurt7864
    @senolkurt7864 5 років тому +1

    With the last changes we made, when we use local login and if the ModelState is not valid, we get null reference exception because of the ExternalLogins property!!

    • @donoboyle8718
      @donoboyle8718 5 років тому

      I changed the login method to take care not to post any null references to the view.
      [HttpPost]
      [AllowAnonymous]
      public async Task Login(LoginViewModel model, string returnUrl)
      {
      if (ModelState.IsValid)
      {
      var result = await signInManager.PasswordSignInAsync(
      model.Email, model.Password, model.RememberMe, false);
      if (result.Succeeded)
      {
      if (!string.IsNullOrEmpty(returnUrl) && Url.IsLocalUrl(returnUrl))
      {
      return Redirect(returnUrl);
      }
      else
      {
      return RedirectToAction("index", "home");
      }
      }
      else
      {
      // in the event of a login failure we make sure to take care of any null values and refresh the external login
      LoginViewModel failmodel = new LoginViewModel
      {
      Email = model.Email,
      Password = model.Password,
      RememberMe = model.RememberMe,
      ReturnUrl = returnUrl,
      ExternalLogins = (await signInManager.GetExternalAuthenticationSchemesAsync()).ToList()
      };
      ModelState.AddModelError(string.Empty, "Invalid Login Attempt");
      return View(failmodel);
      }

      }

      return View(model);
      }

  • @pradeepyadavup8189
    @pradeepyadavup8189 5 років тому

    Sir to buy, how to improve logic building because in ready project we get problems fixing errors and putting new logic,

  • @akashhalwai291
    @akashhalwai291 3 роки тому +1

    from where ApplicatioUser class belongs to?

  • @senolkurt7864
    @senolkurt7864 5 років тому

    Dear Venkat,
    Since we have foreign key constraint, how can we delete users of whom we have data in our AspnetUserLogins Table?

    • @conaxlearn8566
      @conaxlearn8566 4 роки тому

      My guess is to check out userManager.RemoveLoginAsync().

  • @souravsingha3340
    @souravsingha3340 5 років тому

    Best teaching. Please introduced your self with face.i want to see you. Please just 1 video

  • @itsrahimuddinkhan
    @itsrahimuddinkhan 5 років тому

    Nice video. Dear sir, please make sone videos on IndentityServer 4.0

  • @aslantechnitrix3655
    @aslantechnitrix3655 4 роки тому

    i'm just little bit confuse. why we create user for external login. why it doesn't use external login credentials ??

    • @conaxlearn8566
      @conaxlearn8566 4 роки тому

      Regardless using local or external login, you need to store all your users in one table so that you can make sure they have unique user Id in order to perform actions that depends on their user Id, like assigning roles and claims.

  • @_samirdahal
    @_samirdahal 4 роки тому +1

    ah finally got this background music at the end of the video its Crispy Chris Judy 2

  • @gkmishra2009
    @gkmishra2009 5 років тому

    how set only 5 instance of a class will created not more than that??

  • @lifetraveler8008
    @lifetraveler8008 4 роки тому

    Can anyone help me with this
    I have a question about how a project is built in a real life. I am building one for my resume, I am being told to breakdown the project into following
    1. Class Library
    projectName.Application
    projectName.Core
    projectName.Infrastructure
    2. Asp.net Web
    projectName.Web
    I want to know Is this the right way of doing it? . Couldn't find answer on the internet.

  • @javaguitarist
    @javaguitarist 4 роки тому

    I'm on asp.net core 3.1. Has anyone made this work on 3.1? I triple checked all the code. It matches his code. The Google button never hits the ExternalLoginCallback method, only hitting the ExternalLogin(). The redirectUrl is correct. It just keeps going back to the Login page but keeps on adding duplicates of the previous query string. I deleted the gmail user record in AspNetUser when it sort of worked before (never again) and AspNetUserLogins. Cleared Chrome cache and logged out of Google in Chrome. It appears that Google's oauth has changed and this method of using it no longer works.

    • @conaxlearn8566
      @conaxlearn8566 4 роки тому

      Have you resolved it? I am using 3.1 and it is working for me. I'm doing exactly what's taught in the video. Only thing different is that I have to manually install Microsoft.AspNetCore.Authentication.Google. But since you're using 3.1, I'm sure you had done the same.
      The symptom you described did sound like you were redirected from Google back to ExternalLogin action instead of ExternalLoginCallback action.i.e.
      You might have this:
      public IActionResult ExternalLogin(string provider, string returnUrl)
      {
      var redirectUrl = Url.Action("ExternalLogin", "Account", new { ReturnUrl = returnUrl });
      // rest of the code ignored here
      }
      instead of this:
      public IActionResult ExternalLogin(string provider, string returnUrl)
      {
      var redirectUrl = Url.Action("ExternalLoginCallback", "Account", new { ReturnUrl = returnUrl });

      // rest of the code ignored here
      }

    • @opaleyetayo2964
      @opaleyetayo2964 4 роки тому

      Please I am a new programmer. Are we meant to know how to re-write this code by ourself or just know how to tweak the code to work. I have seen a whole lot of codes for the oauth most especially. I will be glad if you can find time to reply me.

    • @conaxlearn8566
      @conaxlearn8566 4 роки тому

      @@opaleyetayo2964 Welcome to the programming world! Video tutorials like this are meant to give you a ground knowledge and examples of how to do the common things. I'm sure when you start to work on real projects you will need to do a lot of Googling on more 'how tos'.

    • @AkshayKumar-dz5ts
      @AkshayKumar-dz5ts 4 роки тому

      This happened to me too today, and i put breakpoints to see whats going on and i found that Url.Action(...) returns null for some reason in asp.net core 3.x
      If you did find a workaround, do let me know.
      Edit: Hello people, if you did face this problem, then just try to add an action with the same name as the one your provided in Url.Action(...) and it should work as expected.
      Behind the scenes : asp.net tries to find this particular action in the controller you mentioned and if it fails to find such a route, then it returns null. This was not the case before core 3.x.

    • @javaguitarist
      @javaguitarist 4 роки тому +1

      Opaleye Tayo I don’t think this is an easy fix. Both asp.net core and Google authentication have changed since this video was made.

  • @manasianil
    @manasianil 4 роки тому +1

    where is applicationuser belong . I get red squiggly

  • @srikanthek737
    @srikanthek737 5 років тому

    Can you please cover Blazor as well simultaneously, ASAP please

  • @joaolopes9926
    @joaolopes9926 Рік тому

    I cannot SignIn in DEBUG MODE "Couldn’t sign you in - This browser or app may not be secure". why? I do everything like the video said.

  • @downunder365
    @downunder365 5 років тому

    I am getting invalid oauth state, or missing state any idea bro?????

  • @prodiptamondal1758
    @prodiptamondal1758 4 роки тому

    Thanks very much.
    Can you help to integrate google authentication with .Net project, instead of .Net core?

  • @hassaanmasood1419
    @hassaanmasood1419 4 роки тому

    What you are explaining is already written in Visual Studio template... Create a video on securing additional data/claims from external provider.. This is something on where there's no proper information available on internet. Even the Microsoft documentation is properly written.

  • @abinashmati1732
    @abinashmati1732 5 років тому

    Please make a video on .net core cookie authentication

  • @mouxez
    @mouxez 3 роки тому

    +

  • @التاريخ-ح4ظ
    @التاريخ-ح4ظ 4 роки тому

    returnUrl = returnUrl ?? Url.Content("~/");
    why write
    this line

    • @deepakpandey9406
      @deepakpandey9406 3 роки тому +2

      That link checks if returnUrl is null, if it's null, then it set the returnUrl content to Home Page ("~/")

  • @osamadammag6303
    @osamadammag6303 9 місяців тому

    AuthenticationFailureException: OAuth token endpoint failure: invalid_client;Description=Unauthorized Unknown location AuthenticationFailureException: An error was encountered while handling the remote login. Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler.HandleRequestAsync() I got this error once I click on the button

  • @gkmishra2009
    @gkmishra2009 5 років тому

    how set only 5 instance of a class will created not more than that??