1

Suppose I have created an Azure AD application and provided the necessesory graph permissions(Application Permissions) to it.

I want to write a code to create a Team in Microsoft Teams from sharepoint page/custom action.

As Example:

POST https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token HTTP/1.1
Host: login.microsoftonline.com
Content-Type: application/x-www-form-urlencoded

client_id=535fb089-9ff3-47b6-9bfb-4f1264799865
&scope=https%3A%2F%2Fgraph.microsoft.com%2F.default
&client_secret=qWgdYAmab0YSkuL1qKv5bPX
&grant_type=client_credentials

I want to hit the above api to retrive the access token from the AzureAD Application to use the MS-Graphs api in my Sharepoint page using javascript or spfx.strong text

Y. Jagtap
  • 113
  • 2

1 Answers1

0

You can not use client credentials flow for browser based client. Also, this is not secure to keep the client secrets in a page.

Two workarounds for you.

1.You can use the msal.js library, but this will need user interaction. Here is the guide.

2.Create your own server as a middleware. Request the access token from your server.

Tony Ju
  • 14,891
  • 3
  • 17
  • 31