Windows Azure AD User Registration through custom UI

I want to use Windows Azure AD for users management for my new Web App. For any new users who want to sing up to my web app they have to register themselves, for this scenario i want to add this new user to Azure AD through Azure providing Create User REST Web service call.

But here i need to pass the Authorization with Bearer Token as a request header for Create User call. I want to know how to obtain Bearer Token from Azure AD for performing user addition.

Since this case is at Home page of the application there are no authentications performed & there will be no Access Token/Bearer Token available.

I believe that this guide and code sample fully covers your scenario.

I have found out answer for my question:- below code snippet is written in Node JS

  1. ensure Your Application has got privilege to read/write access on Azure AD Graph
  2. Authorize the Client by sending following parameter

    var data={
      grant_type: 'client_credentials',
      client_id: "********************************",
      client_secret: "***************************",
      resource: '00000002-0000-0000-c000-000000000000/graph.windows.net@<app_name>.onmicrosoft.com'};
    
    
    
       request.post('https://login.windows.net/<app_name>.onmicrosoft.com/oauth2/token?api-version=1.0', {form: data}, function(e, resp, body) {if (e) console.log(e);
        if (resp.statusCode == 200) {
           var appAccessToken = JSON.parse(body).access_token;
        }});
    
  3. Once we get the access token for the Application, we can use the same access token to perform all the Azure AD Graph operations.