简体   繁体   中英

Microsoft Graph Authentication with MSAL (problem)

I've been struggling to successfully get data from microsoft graph, to be more precise, struggling to get valid authentication token. I followed all instructions and code samples from their github but I cannot get it to work. In image below is my code.

Important fact is that when I hardcode token, which I got from Graph Explorer, it works perfectly... When I try to get data with token obtained with AuthProvider, I get exception Request_ResourceNotFound.

App is registered, access is granted (that's why it works with hardcoded token). NuGet references imported are Microsoft.Graph, Microsoft.Graph.Client, Microsoft.Identity.Client ( https://github.com/AzureAD/microsoft-authentication-library-for-do.net )

If someone can help me with this problem or suggest anything, I would be grateful.

在此处输入图像描述

Problem was that I was requesting "Me" endpoint, while authenticating as application (not user). Exception message was not clear enough to understand that at first...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM