How to register an app using graph sdk in typescript

Eyal Ringwald 40 Reputation points
2024-06-17T20:05:30.35+00:00

Hey , I am having a trouble to find the way to register an app using graph api.
I created an application in Entra manually , which gives me all the needed permissions , and from my delegated app i am creating a new app using the graph SDK.
Now, I want to register the new created application in Entra to my web application (of mine ) as platform "web" and to configure a redirect url.
I created as well the client secret for this application so the only thing that left for me is to update this redirect url.
When I registered it manually it worked . can you help me to automate it ?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,161 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
20,246 questions
0 comments No comments
{count} votes

Accepted answer
  1. CarlZhao-MSFT 39,181 Reputation points
    2024-06-18T03:24:22.4533333+00:00

    Hi @Eyal Ringwald

    Try the following script:

    const options = {
    	authProvider,
    };
    
    const client = Client.init(options);
    
    const application = {displayName: 'Display name',web: {redirectUris: ['https://xxxxxxxxxxxxxxxx']}};
    
    await client.api('/applications')
    	.post(application);
    

    Before this, please ensure that you have correctly instantiated the client.

    Hope this helps.

    If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.


0 additional answers

Sort by: Most helpful