这是我到目前为止所拥有的,但我似乎无法找到 .filter(s),是否以其他方式完成?
IGroupCollectionRequest request = graphServiceClient.groups().buildRequest();
IGroupCollectionPage page = request.get();
IGroupCollectionRequestBuilder builder = page.getNextPage();
while (builder != null) {
request = builder.buildRequest();
page = request.get();
builder = page.getNextPage();
}
Run Code Online (Sandbox Code Playgroud) java azure-active-directory microsoft-graph-sdks microsoft-graph-api
有谁知道如何通过 MS Graph API 创建 excel 和 ppt 文件?我们正在尝试利用 MS Graph API 在单击按钮时创建 word/excel/ppt 文件,虽然我们发现了如何创建 word 文件,但即使 api 成功响应,创建的 excel 和 powerpoint 文件也已损坏。下面的端点适用于 word 文件。我们现在一直在使用图形 API 资源管理器 ( https://developer.microsoft.com/en-us/graph/graph-explorer# )。任何帮助,将不胜感激!
POST https://graph.microsoft.com/v1.0/drives/{Drive ID}/root/children/
Request Body:
{
"name": "FileTest6.docx",
"file":{
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 C# 图形 sdk 将文件上传到 Sharepoint Online 文档库,但未能成功。
我可以获取驱动器/库,但是如果我将它作为驱动器获取,则 Root 为空,并且出现异常。如果我将其作为列表处理,则似乎无法使用 CreateUploadSession 方法。
以列表形式获取文档库有效:
await graphClient.Sites[SPUrl + ":"].Sites[SpPath + ":"].Lists[libId].Request().GetAsync();
Run Code Online (Sandbox Code Playgroud)
通过驱动器 ID 获取文档库作为驱动器似乎不起作用:
var drive = await graphClient.Sites[SPUrl + ":"].Sites[SpPath + ":"].Drives[driveId].Request().GetAsync();
Run Code Online (Sandbox Code Playgroud)
将文档库作为其列表的驱动器执行以下操作:
var drive = await graphClient.Sites[SPUrl + ":"].Sites[SpPath + ":"].Lists[libId].Drive.Request().GetAsync();
Run Code Online (Sandbox Code Playgroud)
但是尝试获取该驱动器的根目录会导致“错误请求:指定的 URL 无效”。尝试 Drive.Items.Request() 也是如此。但据我所知,我需要有驱动器的根来做到这一点:
var uploadSession = await graphClient.Sites[SPUrl + ":"].Sites[SpPath + ":"].Lists[libId].Drive.Root.ItemWithPath(file.FileName).CreateUploadSession().Request().PostAsync();
Run Code Online (Sandbox Code Playgroud)
但是我有三个文档库,它们都将 Root 显示为空。显然我错过了一些东西,但我不清楚是什么。
希望我错过了一些非常简单的东西。根据此文档获取访问令牌,我需要点击以下网址:
https://login.live.com/oauth20_authorize.srf?client_id={client_id}&scope={scope}
&response_type=token&redirect_uri={redirect_uri}
Run Code Online (Sandbox Code Playgroud)
到目前为止,这似乎是我得到的返回 url 包含的工作
/#access_token=EwAYA61DBAAUcSSzo.......
Run Code Online (Sandbox Code Playgroud)
根据上面的令牌流文档,
您可以使用 access_token 的值向 OneDrive API 发出请求。
根据这个页面,
您的应用程序通过 HTTP 标头在每个请求中提供访问令牌:
授权:承载 {token}
运行 curl 时,我给了它我之前给定的确切标记,
curl -X GET \
https://graph.microsoft.com/v1.0/drive \
-H 'Authorization: Bearer EwAYA61DBAAUcSSzoTJJs.....
{
"error": {
"code": "InvalidAuthenticationToken",
"message": "CompactToken parsing failed with error code: 8004920A",
"innerError": {
"request-id": "8780c600-2b7f-45a0-b484-7eca9dfd2697",
"date": "2019-01-25T19:33:22"
}
}
}
Run Code Online (Sandbox Code Playgroud)
为什么他们提供的令牌不起作用?
到目前为止我尝试过的:
需要注意的一件事:我收到的令牌不是JWT 令牌。谷歌搜索错误代码会发现几个堆栈溢出问题,这些问题似乎暗示图形 api 需要 JWT。如果是这种情况,我是否错过了获取它的步骤?
我正在尝试使用 Microsoft Graph SDK 来查询 calendarView 端点。我可以使用常规进行此查询,HttpClient但为了方便起见,我希望通过 SDK 执行此操作。我将尝试使用查询参数命中的端点如下所示:
GET /v1.0/me/calendar/calendarView?startDateTime=2019-01-01T00:00:00.0000000&endDateTime=2019-03-01T00:00:00.0000000
我试图通过这种方式通过 Graph SDK 进行调用:
var graphClient = new GraphServiceClient(new PreAuthorizedBearerTokenAuthenticationProvider(accessToken));
var rooms = await graphClient.Me.Events.Request().Filter("start/dateTime eq '2019-01-08T20:00:00.0000000' and end/dateTime eq '2019-01-08T20:00:00.0000000'").GetAsync();
Run Code Online (Sandbox Code Playgroud)
我为此收到了 200 分,但我的回复中没有任何值。如果我删除结束/日期时间部分,我将获得开始/日期时间日的值。似乎过滤器仅适用于特定情况而不适用于范围。有没有人有在范围内过滤的任何提示?
我目前正在开发一个小型管理应用程序,它应该在特定的 Microsoft 日历中创建事件,但我只能作为授权用户为我执行此操作。
是否可以选择在只知道userPrincipalName?
{
"subject": "test",
"body": {
"contentType": "HTML",
"content": "Sample Text"
},
"start": {
"dateTime": "2019-04-04T12:00:00",
"timeZone": "Pacific Standard Time"
},
"end": {
"dateTime": "2019-04-04T14:00:00",
"timeZone": "Pacific Standard Time"
},
"location":{
"displayName":"Testlocation"
}
}
Run Code Online (Sandbox Code Playgroud)
https://graph.microsoft.com/v1.0/users/myPricipalName/calendar/events 有效,但只对我有用。
整个文档有点压倒性
我正在尝试使用在我的 ASP.NET Core 应用程序中经常运行的后台任务(守护进程)在线上传和下载我的共享点中的文件。因为它是后台任务,所以不使用用户身份。相反,我尝试遵循此文档,使用https://graph.microsoft.com/.default范围获取访问令牌,以及让我的企业应用程序在 azure 上具有管理员已授予的特定权限。 
我可以使用我的应用程序的客户端 ID 和机密获取访问令牌。但是,当我尝试在 sharepoint 上的特定站点上请求驱动器时,它只是停顿,提示我它无法到达路径。当我使用我的用户凭据时,我可以完全正常地到达相同的路径。
我想我可能遗漏了一个步骤或一些与管理相关的任务。下面的代码片段显示我可以获得访问令牌,但在获取驱动器时停止。
var client = new ConfidentialClientApplication(id, uri, cred, null, new SessionTokenCache());
var authResult = await client.AcquireTokenForClientAsync(new[] {"https://graph.microsoft.com/.default"});
var token = authResult.AccessToken; // get token successfully
var graphServiceClient = new GraphServiceClient(new DelegateAuthenticationProvider(async request => {request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token)}));
// stalls below
var drives = await graphServiceClient.Sites[<sharepoint_host>].SiteWithPath(<known_path>).Drives.Request().GetAsync();
Run Code Online (Sandbox Code Playgroud)
在 ASP.NET Core 2 应用中使用 Microsoft Graph SDK。
c# azure azure-active-directory microsoft-graph-sdks microsoft-graph-api
我正在尝试更改 Azure AD 用户密码。
用户已经使用隐式流和库在SPA应用程序中进行了身份验证。adal
打电话时:
return await graphClient.Me.Request().UpdateAsync(new User
{
PasswordProfile = new PasswordProfile
{
Password = userPasswordModel.NewPassword,
ForceChangePasswordNextSignIn = false
},
});
Run Code Online (Sandbox Code Playgroud)
我收到此异常:
{"代码:Request_ResourceNotFound\r\n消息:资源“35239a3d-67e3-4560-920a-2e9ce027aeab”不存在或其查询的引用属性对象之一不存在。\r\n\r\n内部错误\r\ n"}
调试我得到的访问令牌,Microsoft Client SDK我看到这个GUID指的是oid和sub属性。见下文:
这是我用来获取令牌的代码:
IConfidentialClientApplication clientApp =
ConfidentialClientApplicationBuilder.Create(Startup.clientId)
.WithAuthority(string.Format(AuthorityFormat, Startup.tenant))
.WithRedirectUri(Startup.redirectUri)
.WithClientSecret(Startup.clientSecret)
.Build();
var authResult = await clientApp.AcquireTokenForClient(new[] { MSGraphScope }).ExecuteAsync();
return authResult.AccessToken;
Run Code Online (Sandbox Code Playgroud)
我在SPA应用程序中使用隐式流。在这样做时,我看到我的用户已通过身份验证并且所有声明都存在。ClaimsPrincipal.Current
我在 GitHub 和 Microsoft Docs 上阅读了很多文档,但我仍然不清楚如何实现这一点。顺便说一下,我正在使用这些 Microsoft Graph 包:
<package id="Microsoft.Graph" …Run Code Online (Sandbox Code Playgroud) authentication change-password access-token microsoft-graph-sdks microsoft-graph-api
我正在寻找一个 Graph API 调用,它可以将 Sharepoint Online 中的所有站点返回给我。
查看枚举站点:https : //docs.microsoft.com/en-us/graph/api/site-list? view = graph-rest-beta & tabs =http
GET https://graph.microsoft.com/beta/sites?filter=siteCollection/root ne null
Run Code Online (Sandbox Code Playgroud)
它似乎没有返回基于组的站点或子站点。
查看站点搜索:https : //docs.microsoft.com/en-us/graph/api/site-search?view=graph-rest-beta&tabs=http
GET https://graph.microsoft.com/beta/sites?search={query}
Run Code Online (Sandbox Code Playgroud)
这可能更有希望,但没有解释“查询”应该如何构建或搜索什么。
我的想法是,由于所有站点 ID 都以租户域开头,因此我可以搜索该域,然后检索租户的每个站点和子站点。但我不确定如何执行该查询。
理想情况下是这样的:
GET https://graph.microsoft.com/beta/sites?search=id like contoso.microsoft.com
Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的公司使用 Microsoft 的 Graph API,并且我正在关注在线文档来完成这项工作。我在 VB .NET 中工作,我正在按照它的说明导入 Microsoft.Graph.Auth 包,当我构建代码时,出现上述错误。请参见下面的截图。
我无法在网上找到解决方案。我不知道这是否与它是预览包有关?这很奇怪,因为这是微软指示我们做的......
Imports Microsoft.Identity.Client
Imports Microsoft.Graph
Imports Microsoft.Graph.Auth
Public Class Graph
Private clientId As String = System.Configuration.ConfigurationManager.AppSettings("GraphClientId")
Private redirectUri As String = System.Configuration.ConfigurationManager.AppSettings("RedirectUri")
Shared tenantID As String = System.Configuration.ConfigurationManager.AppSettings("GraphTenant")
Private clientSecret As String = System.Configuration.ConfigurationManager.AppSettings("GraphSecret")
Public authProvider As ClientCredentialProvider = Nothing
Public Sub Initialize()
Dim confidentialClientApplication As IConfidentialClientApplication = ConfidentialClientApplicationBuilder.Create(clientId).WithTenantId(tenantID).WithClientSecret(clientSecret).Build()
authProvider = New ClientCredentialProvider(confidentialClientApplication)
End Sub
Public Sub GetAllUserTasks()
Initialize()
Dim graphClient As New GraphServiceClient(authProvider)
Dim tasks = graphClient.[Me].Planner.Tasks.Request().GetAsync() …Run Code Online (Sandbox Code Playgroud) c# ×3
azure ×2
.net ×1
access-token ×1
asp.net ×1
asp.net-core ×1
excel ×1
java ×1
nuget ×1
onedrive ×1
sharepoint ×1
vb.net ×1