Hi @Jie Shen ,
Thanks for reaching out.
I understand you are trying to call "/me" endpoint and added delegated permissions to access graph API "/me" endpoint, but you are getting error
"/me request is only valid with delegated authentication flow".
First you need to understand the delegated permissions and application permissions .
Delegated permissions are used by those application which require user interaction or signed in by user whereas application permissions do not require any user interaction and used by those applications which run in the background and consented by admin only beforehand.
Now, to call any API endpoint, we need to get access token with required permissions using different OAuth flows provided by Microsoft Identity Platform. As mentioned by michev, client credential flow does not require user interaction and require application permissions to get the access token.
If you are trying to get the token with that flow, that token does not contain required permissions to call "/me" endpoint.
To call "/me" endpoint, you need to get the access token using authorization grant flow, implicit flow or ROPC flow where user need to sign in to get the access token.
Hope this will help.
Thanks,
Shweta
---------------------------------
Please remember to "Accept Answer" if answer helped you.