在 AAD 应用程序注册中,隐式授予流程为 true;我们已将权限委派给 User.Read 和 User.Read.All。
private static getContext(): Msal.UserAgentApplication {
if (AuthenticationService.Context) return AuthenticationService.Context;
const logger = new Msal.Logger((_logLevel, message, _piiEnabled) => {
console.log(message);
}, { level: Msal.LogLevel.Verbose, correlationId: "12345" });
AuthenticationService.Context = new Msal.UserAgentApplication(
Environment().authentication.clientId,
AuthenticationService.getAuthority(),
(errorDesc, token, error, _tokenType) => {
if (token) {
AuthenticationService.isAuthenticated = true;
AuthenticationService.accessToken = token;
} else {
const localizedError: string = LocalizationService.localize(error);
alert(localizedError !== error ? localizedError : errorDesc);
}
},
{
logger: logger,
storeAuthStateInCookie: true,
state: "12345",
cacheLocation: "localStorage" …Run Code Online (Sandbox Code Playgroud) 除了检索用户日历的日历视图(代表用户)之外,我们还努力尝试通过 Graph API 使用
https://graph.microsoft.com/beta/users/room1@ourdomain.com/calendarView. 这是一个痛苦的过程,因为我们遇到了很多问题,目前被困在以下404响应中:
https://graph.microsoft.com:443/v1.0/users/room1@ourdomain.com/calendarView?startDateTime=2018-12-04T23:00:00.000Z&endDateTime=2019-02-10T22:59:59.999Z
{
"error": {
"code": "ErrorItemNotFound",
"message": "The specified object was not found in the store.",
"innerError": {
"request-id": "358a003a-57a4-4f0e-91da-edc17c1fa2d8",
"date": "2018-12-12T07:38:33"
}
}
}
Run Code Online (Sandbox Code Playgroud)
房间的电子邮件地址已经过双重检查并且资源存在,因为我们可以使用它创建约会,并且当我们检索在该位置有约会的用户的日历时,它甚至会在响应中返回。
应用程序权限和 OAuth2 范围设置为:openid email profile offline_access https://graph.microsoft.com/Calendars.Read https://graph.microsoft.com/Calendars.Read.Shared https://graph.microsoft.com/User.Read
https://graph.microsoft.com/User.ReadBasic.All https://graph.microsoft.com/User.Read.All,因此根据文档判断,这应该不是问题。
有谁知道如何解决这个问题?
我正在尝试从我的 Java 应用程序连接到 Microsoft Share Point。Microsoft Graph SDK for Java 的文档不是很清楚。
我正在尝试启动 Graph 客户端,同时通过自定义 GUI 或配置文件提供所需的凭据。
我正在尝试按照以下方式进行但可以
IGraphServiceClient client = GraphServiceClient.builder().authenticationProvider(authenticationProvider).buildClient();
Run Code Online (Sandbox Code Playgroud)
我需要“authenticationProvider”对象是一个实现 IAuthenticationProvider 的类,但是它不清楚要添加什么参数或如何创建这个对象。有没有人以前尝试过这个,构建客户端并提供所需凭据的正确方法是什么?
当您从 Graph API 收到“UnknownError”时,有人知道该怎么做吗?或者问微软合适的网站?
谢谢
请求:https : //graph.microsoft.com/v1.0/users/[ USER_ID]/ messages?$select=id,receivedDateTime&$filter=receivedDateTime+ge+2016-09-13+and+receivedDateTime+lt+2019 -09-14&$orderby=receivedDateTime+asc&$skip=25651&$top=1
回复:
{
"error": {
"code": "UnknownError",
"message": "",
"innerError": {
"request-id": "1ea27a29-5491-44d2-824a-0aaee9280c40",
"date": "2019-09-13T19:48:30"
}
}
}
Run Code Online (Sandbox Code Playgroud) 我正在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 的两种方法:
{
"changeType": "created,updated,deleted",
"notificationUrl": "https://somewebsite.com/mswebhook/graph/notifications",
"resource": "/teams/{team-id}/channels/{channel-id}/messages",
"expirationDateTime": "2019-12-30T09:41:21Z",
"clientState": "",
"includeResourceData": true,
"encryptionCertificate": "TUlJQklUQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FRNEFNSUlCQ1FLQ0FRQlhFL0xOZjVYYVY4ZFlXbWFuSU9qUwphSnhyUG1tN0dHN0lWOGYwV2RjZDltbUkvaTVXQzhCNFBYaVBKREtKTnVFL2QvMXo5TndSbjR1UFBQQm9sN1BWCmdudVJ6UmZJSVEvUW1TZjYwUi9LUnYybHVlZzVwNW84Qk5UNDczdTRCbVZJVHNBWlF1eG43RGdnUi9JZlQzSVgKelpMdzNXWitDYzJyS1crblpmbUwwU0NiN21EL3RTZ3VqQUJPVEVvS0xBODkvNWhUamhuNzcvWHJzUTYrV1hMVgpKL3NtVDJvU3R3TzBnYXRIRUkwWkRSL0VYNkdVWDRRRVI4M0puS2hPSDJrZzZQNlZUMDFGUEw0Nk5WemZydWE4ClVob052Z0VlQStPY2xBOU5mUUpJQnVKUVFTbGZ0TmhYODJtVEdhVEtBTFN1bWZieUNac1ljQ3l4MXQ5RXF6Qi8KQWdNQkFBRT0=",
"encryptionCertificateId": "id",
"lifecycleNotificationUrl": "https://somewebsite.com/mswebhook/graph/notifications"
}
Run Code Online (Sandbox Code Playgroud)
当这个请求是从邮递员发出时它正在给
{
"error": {
"code": "InvalidRequest",
"message": "System.Security.Cryptography.CryptographicException: Cannot find the requested object.\r\n\r\n at System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr)\r\n at System.Security.Cryptography.X509Certificates.X509Utils._QueryCertBlobType(Byte[] rawData)\r\n at System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromBlob(Byte[] rawData, Object password, X509KeyStorageFlags keyStorageFlags)\r\n at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(Byte[] rawData)\r\n at Microsoft.Graph.Encryptor.Encryptor.ValidateCertificate(String certificate, String& errorMessage) in X:\\bt\\1070414\\repo\\src\\Dev\\Notifications\\Notifications.Azure\\Encryptor\\Encryptor.cs:line 293",
"innerError": {
"request-id": "e578bdba-2c47-41d7-a0da-5395b05e4203",
"date": "2019-12-31T06:57:59"
}
}
}
Run Code Online (Sandbox Code Playgroud)
没有 includeResourceData 属性,订阅和通知工作正常。我在选择加密证书属性时遇到问题。目前我正在加密证书中传递 Base64 位编码的 2048 位 RSA 公钥(在线生成)。
我在 Microsoft Active Directory 中注册了一个多租户应用程序,该应用程序使用管理员同意来获取对 Microsoft Graph API 中某些应用程序范围 API 的访问权限。它使用/token端点获取令牌,然后调用这些图形 API。它工作得很好。
https://docs.microsoft.com/en-us/graph/auth-v2-service#token-request
现在我想增强我的应用程序以访问一些委托(用户)范围 API,这些 API 不允许在应用程序范围内进行访问。我的应用程序已配置为在管理员同意时向管理员请求这些委派权限。但我想以目录中的每个用户的身份调用这些 API ,而不是安装我的应用程序的管理员。
重要的是,让组织中的每个用户单独完成我的应用程序的 OAuth 流程对我来说是不可行的。
那可能吗?我可以通过用我的应用程序令牌交换用户令牌来以某种方式模拟用户吗?管理员是否可以以编程方式执行某些操作,以作为我的应用程序的个人用户生成令牌,就像他们已通过 OAuth 流程一样?
基于 MS 图形文档,我看到我可以更新一个 driveItem(文件)并将其放在特定的共享点驱动器中。该应用程序作为守护程序运行(无需用户登录)。
为此,我使用这个入口点:
PUT /drives/{drive-id}/items/{item-id}/content
Run Code Online (Sandbox Code Playgroud)
我尝试使用主类进行编码并传递现有参数。要更新文档,我调用方法更新文档:
UpdateDocumentResponseModel updatedDocument = fileGraphs.updateDocument(token, DRIVELIBID, DOCUMENTID, INPUTPATH, DOCUPDATE);
Run Code Online (Sandbox Code Playgroud)
被调用的方法旨在构建 URL 并为 PUT 请求准备数据:
public UpdateDocumentResponseModel updateDocument(String accessToken,
String driveLibId,
String documentId,
String inpuPath,
String docName) throws MalformedURLException {
String fullPath = inpuPath + docName;
URL url = new URL("https://graph.microsoft.com/v1.0/drives/" + driveLibId + "/items/" + documentId + "/content");
return requestsBuilder.updateDocument(accessToken, url, fullPath);
}
Run Code Online (Sandbox Code Playgroud)
现在在这个阶段我必须提出请求:
public UpdateDocumentResponseModel updateDocument(String accessToken, URL url, String fullPath) {
UpdateDocumentResponseModel returnValue = new UpdateDocumentResponseModel();
try {
CloseableHttpClient client = …Run Code Online (Sandbox Code Playgroud) 我是 Microsoft Graph API 的新手,我的最终目标是创建一个 Power BI 报告来显示 Microsoft Teams 调用相关矩阵。
从文档中我可以看到 HTTP 示例(https://graph.microsoft.com/beta/communications/callRecords/ {id})。文档中有几件事不清楚。
在特定租户下登录我们系统的任何用户(作为身份验证的身份服务器)都应该能够创建一个在线会议(MS Teams)活动。
我们遵循了使用 Microsoft Graph和Create构建 ASP.NET Core MVC 应用程序并启用事件作为在线会议来创建一个应用程序,该应用程序对组织的AD 用户进行身份验证并允许他将事件创建为在线会议。
我们能够成功实施它,并且能够将活动创建为在线会议。
但这里的确切情况是,在我们的 Web 应用程序中通过身份验证的任何用户(不是 AD 用户)都应该能够创建 MS Teams 会议事件并与应该能够加入会议的其他参与者共享。
我不确定如何实现这一目标。
编辑
或者至少我如何创建 onlineMeeting?我尝试使用客户端凭据提供程序如下
IConfidentialClientApplication confidentialClientApplication = ConfidentialClientApplicationBuilder
.Create("<<App_Id>>")
.WithTenantId("<<Tenant_Id>>")
.WithClientSecret("<<Client_Secret>>")
.Build();
ClientCredentialProvider authenticationProvider = new ClientCredentialProvider(confidentialClientApplication);
GraphServiceClient graphClient = new GraphServiceClient(authenticationProvider);
var onlineMeeting = new OnlineMeeting
{
StartDateTime = DateTimeOffset.Parse("2020-01-15T21:30:34.2444915+05:30"),
EndDateTime = DateTimeOffset.Parse("2020-01-15T22:00:34.2464912+05:30"),
Subject = "User Token Meeting"
};
var meeting = graphClient.Me.OnlineMeetings
.Request() …Run Code Online (Sandbox Code Playgroud)