Where is the API documentation? How do I perform some operations?

Leonardo Ferreira 26 Reputation points
2020-07-01T21:04:45.367+00:00

I would like to know which API I should call to:

  1. Self-Service register a new user
  2. Login

My native app has the screens for each of these and I don't want to use web-views.

I want to PUT /adb2c/Users {email:a@a.com, pass:bla, ... other info ... } and bam! the user is created and later login like POST /adb2c/Users/Login {login:abcd, pass:bla} and get a access token...

how can I do that?

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,471 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Shashi Shailaj 7,581 Reputation points Microsoft Employee
    2020-07-02T04:33:19.163+00:00

    Hello @LeonardoFerreira-1113 ,

    You can call the Microsoft Graph API to interact with your B2C tenant . Please checkout the links on Microsoft Graph Authentication Overview article for more information on how to authenticate to Graph and get a auth token for operations. You can use the Create user API function to create the user . In order to do this you would need to have a graph Application registered in your B2C tenant . More information about working with User objects can be found here. Start with the Basic authentication concepts here in order to understand how to get the auth tokens. There is a Native desktop App tutorial for Azure AD B2C which you can test this with . Its is a native WPF app sample based on .net which you can download from the linked github repo. I am not sure which language you are using but this would give you some idea on how the operations work which you are looking for.

    As per your request I believed that you were trying to use complete Modern authentication architecture within your native app however as I understand , you require a username/password flow where your app will collect the credentials for the user and send the API request to the Azure AD auth system. In this case you actually need to use the ROPC oAUth flow with azure AD for authentication. In other oAuth authentication flows , we provide an embedded web view where the credential is directly provided by the user on Microsoft provided login page and the login screen within the application is designed to show the webview. But if you use ROPC oAuth Authentication flow with Azure AD , you can collect the username and password for the user and then send it to the Azure AD auth endpoint https://login.microsoftonline.com/{Tenant ID or name}/oauth2/v2.0 . For Azure AD b2c specific ROPC setup , please check the MSAL.net B2C considerations article. The following request flow diagram explains how ROPC will work. The client referred in the screenshot is your desktop application.

    11311-ropc2.jpg

    However you cannot use this with Microsoft Accounts(Live Id , Outlook.com or hotmail.com ID , xbox live etc.). And there are other limitations with this flow , that you cannot leverage modern authentication techniques like conditional access and MFA hence its not considered as safe as other flows. If a user who has MFA enabled on their account tries to logon to your app they wont be able to sign in and this is by design. The application would not benefit from single signon as well. As per our documentation for ROPC, you can see the details as marked in below screenshot.

    11301-ropc.jpg

    There is a working sample for ROPC flow which you can test . If there are any issues with the sample , you can always open an issue within the repo on github . You can read more on supported oAuth Authentication flows with Azure AD. I believe the related links would give you a detailed idea about how you can use ROPC flow with Azure AD within your desktop application and what will be the limitations that you will face within your user applications. As mentioned on the ROPC page, it is mostly used in some devops scenarios.

    Hope the above information clarifies your queries. I have linked the articles within the answer. I would suggest you to go through the links and they will definitely help you . In case the information in this post is helpful ,please do accept it as answer so that it can help other members of the community . If you still have any other queries, please do let us know and we will be happy to help.

    Thank you.

    1 person found this answer helpful.