我正在console application用 C#构建一个。
我想调用Microsoft Graph API来访问和编辑我的SharePoint 中的一些 Excel 文件,以便我可以在我的组织中自动执行一些流程。
该应用程序的逻辑很简单。
Azure Active Directory以使用客户端凭据流对这个控制台应用程序进行身份验证,这意味着我们将提供一个 clientsID 和 AppKey。我从 Azure Active Directory > App Registrations 获取了 clientsID 和 AppKey 。

https://graph.microsoft.com/v1.0/me/
{
"error": {
"code": "InvalidAuthenticationToken",
"message": "Access token validation failure. Invalid audience.",
"innerError": {
"request-id": "0a3ec**************",
"date": "2019-10-15T13:54:33"
}
}
}Run Code Online (Sandbox Code Playgroud)
您将在下面找到我的应用程序的完整代码,其中包含获取访问令牌和调用 Graph API 的两种方法: