Hi @Hamza Iqbal
If you want external users to sign in to your app and authenticate, you must configure your app as a multi-tenant app.
Then use the auth code flow to interactively log in the external user in the browser to obtain the authorization code, and use the authorization code to redeem the access token of the graph API.
Note that you must change /{tenant id}
to /common
to allow external users to log in.
1.Request an authorization code in the browser.
https://login.microsoftonline.com/common/oauth2/v2.0/authorize?
client_id={client id}
&response_type=code
&redirect_uri={redirect_uri}
&response_mode=query
&scope=openid offline_access User.Read
&state=12345
2.Redeem token.
https://login.microsoftonline.com/common/oauth2/v2.0/token
client_id={client id}
&scope=openid offline_access User.Read
&code={code}
&redirect_uri={redirect_uri}
&grant_type=authorization_code
&client_secret={client_secret}
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.