虽然我已经找到了尽可能多的文档,但我无法找到https://graph.microsoft.io/的招摇文件.
似乎有一对夫妇在这个API的变化,我已经看到了Office 365的图形API和Azure的图形API的参考,但我认为,微软图形是最新的统一版本,并提供我以后的功能.
我想使用Microsoft Flow,我很惊讶它没有集成为开箱即用的API.要使用Flow注册Custom API,您需要提供一个swagger文件,因此问题.
我正在通过Mircosoft Graph访问Sharepoint站点的文档库,但到目前为止还没有运气.
这是我的设置:
我有两个网站
https://mydomain.sharepoint.com
https://mydomain.sharepoint.com/teams/MyTestSite
当我对https://graph.microsoft.com/v1.0/drives进行api调用时,响应不包含第二个站点的文档库ID(https://mydomain.sharepoint.com/teams/MyTestSite).
我已经完成了文档,但没有找到任何关于如何完成此任务的内容.如果有人对此有任何疑问,请分享.
谢谢.
My application sends email using Microsoft Graph. We followed the documentation, this was working as expected for almost a year:
https://graph.microsoft.com/v1.0/users/me/microsoft.graph.sendmail
Run Code Online (Sandbox Code Playgroud)
Since 3/8/2019, the same code sendmail
API in PROD started failing with the HTTP 400 - Bad Request
:
{
"error": {
"code": "TargetIdShouldNotBeMeOrWhitespace",
"message": "Id is malformed.",
"innerError": {
"request-id": "0de5a4eb-dac4-4d98-a4b4-178e503a6657",
"date": "2019-03-19T17:16:20"
}
}
}
Run Code Online (Sandbox Code Playgroud)
As a part of the investigation, we found that the SendMail documentation has a different URL used in the examples than …
我想列出所有用户.对于每个用户,我需要显示特定于该用户的角色和组.
我试过了:
https://graph.microsoft.com/v1.0/users?$expand=memberOf
Run Code Online (Sandbox Code Playgroud)
但它给出了完全相同的结果:
https://graph.microsoft.com/v1.0/users
Run Code Online (Sandbox Code Playgroud)
根据用户对象的文档(http://graph.microsoft.io/en-us/docs/api-reference/v1.0/resources/user),我应该能够列出用户对象的角色和组用户通过使用memberOf关系.
我可以通过为每个用户执行一个请求(使用https://graph.microsoft.com/v1.0/users/{user_id}/getMemberObjects
)来获取每个用户所需的角色和组,但它有点慢和过度杀伤.
我错过了什么?
我正在使用MSAL并且有一位用户收到以下错误:
{
"error":{
"code":"ResourceNotFound",
"message":"Resource could not be discovered.",
"innerError":{
"request-id":"99b44a33-e5cd-4b69-9730-32d72e1f4ebf",
"date":"2016-12-11T03:51:37"
}
}
}
Run Code Online (Sandbox Code Playgroud)
代码是默认的MSAL演示代码:
public async Task<ActionResult> ReadMail()
{
try
{
string signedInUserID = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value;
ConfidentialClientApplication cca = new ConfidentialClientApplication(clientId, null,
new ClientCredential(appKey), new MSALSessionCache(signedInUserID, this.HttpContext));
string[] scopes = { "Mail.Read" };
AuthenticationResult result = await cca.AcquireTokenSilentAsync(scopes);
HttpClient hc = new HttpClient();
hc.DefaultRequestHeaders.Authorization =
new System.Net.Http.Headers.AuthenticationHeaderValue("bearer", result.Token);
HttpResponseMessage hrm = await hc.GetAsync("https://graph.microsoft.com/v1.0/me/messages");
string rez = await hrm.Content.ReadAsStringAsync();
ViewBag.Message = rez;
return View();
}
catch (MsalSilentTokenAcquisitionException)
{
ViewBag.Relogin = …
Run Code Online (Sandbox Code Playgroud) 我正在尝试向Azure AD应用程序添加所需的权限.我已经知道如何通过PATCH REST调用从下载的清单中复制信息,例如
"requiredResourceAccess": [
{
"resourceAppId": "00000003-0000-0000-c000-000000000000",
"resourceAccess": [
{
"id": "7b9103a5-4610-446b-9670-80643382c1fa",
"type": "Scope"
},
{
"id": "5df07973-7d5d-46ed-9847-1271055cbd51",
"type": "Scope"
}
]
}
]
Run Code Online (Sandbox Code Playgroud)
正如Christer Ljung在他的博客http://www.redbaronofazure.com/?page_id=181上所解释的那样.
但神秘之处仍然是如何"转换"人类可读的范围,例如Mail.Read
这些晦涩的guid.我在http://blah.winsmarts.com/2015-1-Programmatically_register_native_apps_in_Azure_AD_or_Office_365.aspx上阅读了Sahil Malik的以下博客,该博客解释了如何获取特定ServicePrincipal的可用guid列表.例如,通过http get to https://graph.windows.net/<tenant-id>/servicePrincipals()?api-version=1.6&$filter=appId%20eq%20'00000002-0000-0ff1-ce00-000000000000'>
(Exchange),但是当我尝试获取ServicePrincipal的可用范围列表00000003-0000-0000-c000-000000000000
(我相信Graph API的范围)时,返回值只是空的.
有趣的是,通过Fiddler,我能够捕获一个http post请求,其中包含通过Azure Portal添加权限时的所有guid.
任何人都知道如何以编程方式执行此操作?
我在Office365中拥有和管理员帐户,其中一个应用程序可以完全访问任何与交换相关的内容.我正在编写一个具有用例的应用程序,我需要在用户的邮箱中创建所有规则.这包括规则名称,内容等.
理想情况下,这应包括设备之间的Active Sync设置,eDiscovery邮箱的权限等.
我没有看到图API中的那些支持.有没有办法获得这些信息?
我使用https://graph.microsoft.com/beta/me/photo/ $ value API来获取outlook用户的个人资料图片.我得到了一个关于在rest-client中运行上述API的图像.API的内容类型是"image/jpg"
但是,在Node.js中,API的响应如下:
????\u0000\u0010JFIF\u0000\u0001\u0001\u0000\u0000\u0001\u0000\u0001\u0000\u0000??\u0000?\u0000\u0005\u0005\u0005\u0005\u0005\u0005\u0006\u0006\u0006\u0006\b\t\b\t\b\f\u000b\n\n\u000b\f\u0012\r\u000e\r\u000e\r\u0012\u001b\u0011\u0014\u0011\u0011\u0014\u0011\u001b\u0018\u001d\u0018\u0016\u0018\u001d\u0018+"\u001e\u001e"+2*(*2<66<LHLdd?\u
Run Code Online (Sandbox Code Playgroud)
我用'fs'来创建一个图像文件.代码如下:
const options = {
url: "https://graph.microsoft.com/beta/me/photo/$value",
method: 'GET',
headers: {
'Accept': 'application/json',
'Authorization': `Bearer ${locals.access_token}`,
'Content-type': 'image/jpg',
}
};
request(options, (err, res, body) => {
if(err){
reject(err);
}
console.log(res);
const fs = require('fs');
const data = new Buffer(body).toString("base64");
// const data = new Buffer(body);
fs.writeFileSync('profile.jpg', data, (err) => {
if (err) {
console.log("There was an error writing the image")
}
else {
console.log("The file is written successfully");
}
});
});
Run Code Online (Sandbox Code Playgroud)
文件写入成功,但.jpg …
我正在创建一个使用Microsoft Graph API连接到Microsoft Graph的控制台应用程序(如https://github.com/microsoftgraph/console-csharp-connect-sample所示)。一切工作正常,但我想知道是否存在一种方法可以验证用户身份(当我已经知道其用户名/密码时)而无需他们在界面上显示的“ Sing in your account”窗口中手动输入其凭据。桌面。这个想法基本上是在无人值守的情况下运行应用程序,因此用户无需在应用程序启动时输入其凭据。我找不到与此主题相关的任何信息。那有可能吗?
编辑
在跟踪@DanSilver发布的关于没有用户访问的链接之后,我尝试了该链接中建议的示例(https://github.com/Azure-Samples/active-directory-dotnet-daemon-v2)。尽管那是一个MVC应用程序,它迫使用户进行身份验证(正是我要避免的身份),但我还是设法在控制台应用程序中使用了该示例中的部分身份验证代码。通过对https://login.microsoftonline.com/myTenantId/adminconsent的请求为应用程序手动授权后, 我可以在无需用户交互的情况下连接到Graph的控制台应用程序中创建GraphServiceClient。因此,我将答案标记为有效。万一有人处于相同的情况下,则将GraphServiceclient创建为:
GraphServiceClient graphServiceClientApplication = new GraphServiceClient("https://graph.microsoft.com/v1.0", new DelegateAuthenticationProvider(
async (requestMessage) =>
{
string clientId = "yourClientApplicationId";
string authorityFormat = "https://login.microsoftonline.com/{0}/v2.0";
string tenantId = "yourTenantId";
string msGraphScope = "https://graph.microsoft.com/.default";
string redirectUri = "msalXXXXXX://auth"; // Custom Redirect URI asigned in the Application Registration Portal in the native Application Platform
string clientSecret = "passwordGenerated";
ConfidentialClientApplication daemonClient = new ConfidentialClientApplication(clientId, String.Format(authorityFormat, tenantId), redirectUri, new ClientCredential(clientSecret), null, new TokenCache()); …
Run Code Online (Sandbox Code Playgroud) 我目前正在尝试执行一些任务,这些任务涉及从共享的OneDrive文件夹列出,上传和下载文件。该文件夹可通过已登录的用户OneDrive访问(在其根文件夹中可见)。到目前为止,清单部分使用以下代码运行良好:
string remoteDriveId = string.Empty;
private GraphServiceClient graphClient { get; set; }
// Get the root of the owners OneDrive
DriveItem ownerRoot = await this.graphClient.Drive.Root.Request().Expand("thumbnails,children($expand=thumbnails)").GetAsync();
// Select the shared folders general information
DriveItem sharedFolder = ownerRoot.Children.Where(c => c.Name == "sharedFolder").FirstOrDefault();
// Check if it is a remote folder
if(sharedFolder.Remote != null)
{
remoteDriveId = item.RemoteItem.ParentReference.DriveId;
// Get complete Information of the shared folder
sharedFolder = await graphClient.Drives[remoteDriveId].Items[sharedFolder.RemoteItem.Id].Request().Expand("thumbnails,children").GetAsync();
}
Run Code Online (Sandbox Code Playgroud)
因此,显然我需要从与另一个OneDrive共享的OneDrive中检索共享文件夹信息。对我而言,下一部分是列出此共享文件夹的内容,它也可以像这样很好地工作:
foreach (DriveItem child in sharedFolder.Children)
{
DriveItem childItem = await graphClient.Drives[remoteDriveId].Items[child.Id].Request().Expand("thumbnails,children").GetAsync(); …
Run Code Online (Sandbox Code Playgroud) microsoft-graph ×10
office365 ×4
c# ×3
azure ×1
fs ×1
javascript ×1
node.js ×1
office365api ×1
onedrive ×1
sharepoint ×1
swagger ×1