Referring to Azure B2C check user exist or not? I am facing an issue while trying to check if user emailId exists in B2C. Below is the code which I referred to implement from the above mention stackoverflow link where @Saurab Kulkarni suggested the approach, which is close to my requirement, but it always return Status= AwaitingForActivation. Could you please help?
public interface IGraphHelper
{
Task<User> CheckUserByEmailId(string email, CancellationToken ct);
}
public class GraphHelper : IGraphHelper
{
private readonly ADOptions _adOptions;
public async Task<User> CheckUserByEmailId(string email, CancellationToken ct)
{
IConfidentialClientApplication confidentialClientApplication =
ConfidentialClientApplicationBuilder
.Create(_adOptions.ClientId)
.WithTenantId(_adOptions.TenantId)
.WithClientSecret(_adOptions.ClientSecret)
.Build();
ClientCredentialProvider authProvider = new
ClientCredentialProvider(confidentialClientApplication);
GraphServiceClient graphClient = new GraphServiceClient(authProvider);
var filter = $"identities/any(c:c/issuerAssignedId eq '{email}' and c/issuer eq '{_adOptions.Issuer}')";
var request = graphClient.Users.Request()
.Filter(filter)
.Select(userSelectQuery) //What is userSelectQuery here?
.Expand(e => e.AppRoleAssignments);
var userCollectionPage = await request.GetAsync(ct);
return userCollectionPage.FirstOrDefault();
} }
//Home Controller//
public JsonResult CheckName(string emailId, CancellationToken ct)
{
string email = emailId;
bool status;
var result = _graphHelper.CheckUserByEmailId(email, ct);
return Json(status);
}`
Error:
=================================
Error Screenshot:
Always returns: Status: Waiting for Activation.