Hi, I am trying to get external login with azure b2c to work in umbraco version: 9.4 (+ uSync package installed)
I have added openid connect external login to umbraco and added MicrosoftMemberExternalLoginProviderOptions. I return a Challenge from controller action with following code:
class MicrosoftMemberExternalLoginProviderOptions is from docs pages:
public const string SchemeName = "Microsoft";
public void Configure(string name, MemberExternalLoginProviderOptions options)
{
if (name != Constants.Security.MemberExternalAuthenticationTypePrefix + SchemeName)
{
return;
}
Configure(options);
}
public void Configure(MemberExternalLoginProviderOptions options) =>
options.AutoLinkOptions = new MemberExternalSignInAutoLinkOptions(
// Must be true for auto-linking to be enabled
autoLinkExternalAccount: true,
defaultCulture: null,
defaultIsApproved: true,
defaultMemberTypeAlias: "Member",
defaultMemberGroups: Array.Empty<string>()
)
{
OnAutoLinking = (autoLinkUser, loginInfo) =>
{
},
OnExternalLogin = (user, loginInfo) =>
{
return true;
},
};
Redirect to Microsoft login works, and redirect back to /blogs works as well, but it does not create local account. I thought implementing IConfigureNamedOptions< MemberExternalLoginProviderOptions > will take care of that.
I am facing the same problem. The setup pipeline doesn't reach the configuration for MicrosoftMemberExternalLoginProviderOptions. And to be frank, I don't really know why it should reach it. I have the feeling some configuration or convention is missing from the documentation, but I can't figure out what.
Do this before you call .AddMemberExternalLogins(). I made an extension method to do it all
public static IUmbracoBuilder AddExternalLogins(this IUmbracoBuilder builder, IConfiguration config)
{
builder.Services.ConfigureOptions<GoogleMemberExternalLoginProviderOptions>();
builder.AddMemberExternalLogins(logins =>
{
logins.AddMemberLogin(
memberAuthenticationBuilder =>
{
memberAuthenticationBuilder.AddGoogle(
// The scheme must be set with this method to work for the back office
memberAuthenticationBuilder.SchemeForMembers(GoogleMemberExternalLoginProviderOptions.SchemeName),
options =>
{
options.ClientId = config.GetValue<string>("MYKEYPATH");
options.ClientSecret = config.GetValue<string>("MYKEYPATH");
//options.CallbackPath = "";
});
});
});
return builder;
}
Facing the same problem here, using OpenId Connect. Login through MVC button works great, but login through controller seems to be an impossible task.
Webapi code for login that redirects to login provider:
[HttpGet("~/signin")]
public ActionResult SignIn()
{
return new ChallengeResult("UmbracoMembers.OpenIdConnect", new AuthenticationProperties
{
RedirectUri = "/about-us", //test url
IsPersistent = true //makes no difference
});
}
token is accepted, all is 100% well, claims 100%, isauthenticated=true. But it does not trigger OnAutoLinking or OnExternalLogin methods, and cookies not set, so im still not logged in
using umbraco v13 this site should only be an api using a react frontend, so i need to use an api for login
problem wit external member login + autolinking
Hi, I am trying to get external login with azure b2c to work in umbraco version: 9.4 (+ uSync package installed)
I have added openid connect external login to umbraco and added MicrosoftMemberExternalLoginProviderOptions. I return a Challenge from controller action with following code:
ConfigureServices:
class MicrosoftMemberExternalLoginProviderOptions is from docs pages:
Redirect to Microsoft login works, and redirect back to /blogs works as well, but it does not create local account. I thought implementing IConfigureNamedOptions< MemberExternalLoginProviderOptions > will take care of that.
This are requests from browser:
What am I missing? Thank you.
I am facing the same problem. The setup pipeline doesn't reach the configuration for MicrosoftMemberExternalLoginProviderOptions. And to be frank, I don't really know why it should reach it. I have the feeling some configuration or convention is missing from the documentation, but I can't figure out what.
In the IUmbracoBuilder you need to register your MicrosoftMemberExternalLoginProviderOptions class like so.
Do this before you call .AddMemberExternalLogins(). I made an extension method to do it all
But commissar had registered MicrosoftMemberExternalLoginProviderOptions before services.AddUmbraco.
What's the difference between calling it in extension method or directly from ConfigureServices?
I'm asking because I followed documentation and I have similar problem like commissar. Is there any demo I could download and try?
Facing the same problem here, using OpenId Connect. Login through MVC button works great, but login through controller seems to be an impossible task. Webapi code for login that redirects to login provider:
token is accepted, all is 100% well, claims 100%, isauthenticated=true. But it does not trigger OnAutoLinking or OnExternalLogin methods, and cookies not set, so im still not logged in
using umbraco v13 this site should only be an api using a react frontend, so i need to use an api for login
is working on a reply...