Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Enabling Phone Method for Azure AD B2C User via Graph API #2549

Closed
Vijaykumarj opened this issue Jun 14, 2024 · 2 comments
Closed
Labels
Status: No recent activity status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close type:bug A broken experience

Comments

@Vijaykumarj
Copy link

Describe the bug

I am currently working on enabling the phone method for Azure AD B2C users using the Graph API, specifically using the PhoneMethods for authentication. However, I am encountering an issue where the operation fails with the error message: "Cannot enable SMS sign-in on phone auth method as the credential policy is not enabled on user".

Expected behavior

Phone method should be add to the user.

How to reproduce

`if (adUser != null)
{
var phoneMethods = graphClient.Users[adUser.Id].Authentication.PhoneMethods.GetAsync().Result;

var requestBody = new PhoneAuthenticationMethod
{
    PhoneNumber = "**********",
    PhoneType = AuthenticationPhoneType.Mobile,
    SmsSignInState = AuthenticationMethodSignInState.Ready
};

var phoneMethodsRes = graphClient.Users[adUser.Id].Authentication.PhoneMethods.PostAsync(requestBody).Result;

if (phoneMethodsRes != null)
{
    graphClient.Users[adUser.Id].Authentication.PhoneMethods[$"{phoneMethodsRes.Id}"].EnableSmsSignIn.PostAsync().Result;
}

var phoneMethodsLast = graphClient.Users[adUser.Id].Authentication.PhoneMethods.GetAsync().Result;

}
catch (Exception exp)
{
Console.WriteLine($"Exception Caught: {exp.Message}");
}`

SDK Version

5.56.0

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output

Click to expand log ```

Microsoft.Graph.Models.ODataErrors.ODataError: Can not enable Sms sign in on phone auth method as the credential policy is not enabled on user.
at Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.ThrowIfFailedResponse(HttpResponseMessage response, Dictionary2 errorMapping, Activity activityForAttributes, CancellationToken cancellationToken) at Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.SendNoContentAsync(RequestInformation requestInfo, Dictionary2 errorMapping, CancellationToken cancellationToken)
at Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.SendNoContentAsync(RequestInformation requestInfo, Dictionary2 errorMapping, CancellationToken cancellationToken) at Microsoft.Graph.Users.Item.Authentication.PhoneMethods.Item.EnableSmsSignIn.EnableSmsSignInRequestBuilder.PostAsync(Action1 requestConfiguration, CancellationToken cancellationToken)
at Program.Main(String[] args) in C:\Projects\GraphClient\Program.cs:line 76

</details>


### Configuration

- OS: Windows 11
-  .Net Core 6

![image](https://github.com/microsoftgraph/msgraph-sdk-dotnet/assets/26544969/5c5c61c6-bb99-4c7a-a5aa-770a6b8d5278)
![image (1)](https://github.com/microsoftgraph/msgraph-sdk-dotnet/assets/26544969/4096a988-bd2a-4892-a5c9-42daaf028fd4)


### Other information

_No response_
@Vijaykumarj Vijaykumarj added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Jun 14, 2024
@andrueastman
Copy link
Member

Thanks for raising this @Vijaykumarj

The error seems to suggest that the API is failing on the request due to the credential policy on the specific user. Any chance you can post the question at https://aka.ms/graphfeedback to get feedback from the API owners on what could be issue here?

@andrueastman andrueastman added status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close and removed status:waiting-for-triage An issue that is yet to be reviewed or assigned labels Jun 25, 2024
Copy link
Contributor

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: No recent activity status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close type:bug A broken experience
Projects
None yet
Development

No branches or pull requests

2 participants