Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Equivalent to GetExternalAuthenticationTypes() in ASP.NET Core 2.0?

I've spent a long time trying to convert an ASP.NET 5.0 app to ASP.NET Core 2 and I just can't find a few things. I'm trying to get the list of external providers (Google, Facebook, etc.) that are supported by the current installation. Pre Core, I would have used:

Context.GetOwinContext().Authentication.GetExternalAuthenticationTypes()

Of course, I can't use that anymore due to the OWIN reference, but I haven't been able to find a similar function anywhere else either. I don't want to have to set it manually. Is there a sample of using this to create a nice social login page? Any help would be much appreciated!

like image 216
Arian Kulp Avatar asked Feb 03 '26 22:02

Arian Kulp


1 Answers

Do you need SignInManager.GetExternalAuthenticationSchemesAsync?

var loginProviders = (await SignInManager.GetExternalAuthenticationSchemesAsync()).ToList();
        <div>
            <p>
                @foreach (var provider in loginProviders)
                {
                    <button type="submit" class="btn btn-default" name="provider" value="@provider.Name" title="Log in using your @provider.DisplayName account">@provider.DisplayName</button>
                }
            </p>
        </div>
    </form>
}
like image 170
Dmitry Avatar answered Feb 05 '26 14:02

Dmitry



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!