我正在与Microsoft Graph一起玩,以直接使用REST API(没有SDK)从我的应用程序访问Azure Active Directory。
根据文档,我应该能够从用户id
或userPrincipalName
使用中检索用户/users/{id | userPrincipalName}
。
这确实有效,但不适用于Guest用户。对于Guest用户userPrincipalName
来说就像是name_originaldomain#EXT#@mydomain.onmicrosoft.com
,并试图使用户获得结果404 Not Found
。
这是我当前正在使用的代码:
graphClient = new HttpClient();
graphClient.BaseAddress = new Uri("https://graph.microsoft.com/v1.0/");
graphClient.DefaultRequestHeaders.Add("Authorization", $"{token.TokenType} {token.AccessToken}");
HttpRequestMessage request = new HttpRequestMessage(
HttpMethod.Get,
$"users/{Uri.EscapeUriString(username)}"
);
HttpResponseMessage response = await graphClient.SendAsync(request);
if (response.IsSuccessStatusCode)
{
return await response.Content.ReadAsAsync<UserResult>();
}
// I am here with a 404
Run Code Online (Sandbox Code Playgroud)
我是否缺少某些东西或做错了什么?
我一直在尝试搜索我的SharePoint网站.我能够获得单个驱动器的结果:
xxx.sharepoint.com,xxxxxx-xxxx-xxxx-xxxx-xxxxxx,xxxxx-xxxx-xxxx-xxxx-xxxxxx/drives/xxxxxxxxx/search(q='{content}')
但如果我进行相同的搜索drive/root
,我不会得到任何结果:
xxx.sharepoint.com,xxxxxx-xxxx-xxxx-xxxx-xxxxxx,xxxxx-xxxx-xxxx-xxxx-xxxxxx/drive/root/search(q='{content}')
我们基本上希望在整个子网站上执行搜索.
我将在Angular Web应用程序中使用Microsoft Graph API。
首先,我使用msal库进行连接。 当我尝试使用配置文件登录时,出现此错误
我已经按照官方git示例中提到的配置了我的应用
MsalModule.forRoot({
clientID: "Tenant ID",
authority: "https://login.microsoftonline.com/common/",
redirectUri: "http://localhost:4200/",
validateAuthority : true,
popUp: true
}),
Run Code Online (Sandbox Code Playgroud)
身份验证正在进行,我得到了令牌。
然后,当我进入主页时,我再次向Microsoft Graph API发出请求,以使用该令牌获取用户信息。
getProfile() {
let header= new Headers();
let tokenid= sessionStorage.getItem('msal.idtoken');
header.set('Authorization', 'Bearer ' + tokenid)
let url ="https://graph.microsoft.com/v1.0/me/"
return this.http.get(url,{headers:header});
}
Run Code Online (Sandbox Code Playgroud)
}
我收到响应401 Unauthorized错误:
{
"error": {
"code": "InvalidAuthenticationToken",
"message": "Access token validation failure.",
"innerError": {
"request-id": "xxxxxx",
"date": "2018-10-09T22:58:41"
}
}
}
Run Code Online (Sandbox Code Playgroud)
我不知道为什么MG API不接受我的令牌,我是否使用了错误的授权URL?
更新:我知道实际上我得到的id_token与访问令牌不同。如何从MSAL库获取Access令牌以进行MS GRAPH API调用?:
javascript azure-active-directory microsoft-graph azure-ad-msal angular
我不是python的新手(也不是专业人士),但这是我第一次尝试这种方法。
我想使用python脚本将文件上传到OneDrive。听起来很简单吧?好吧,显然我可以处理的更多。
从到目前为止我所看到的,我正在使用的onedrive-sdk-python显然不再起作用了(来源:https : //github.com/OneDrive/onedrive-sdk-python/issues/119),因为它已经退役了。
我猜要使用的新SDK是适用于Microsoft Graph的SDK。但是github(https://github.com/MicrosoftArchive/msgraph-sdk-python)并未真正提到如何设置新的Oauth2身份验证,获取令牌并在python中使用客户端。身份验证部分中提到的链接对我不起作用,我收到如下错误消息:“ AADSTS900144:请求正文必须包含以下参数:'client_id'。”
我在stackoverflow上查找了类似的问题,但其中大多数是关于旧的onedrive-sdk的,而我能找到的最新版本已经快三个月了。那里的回应是它仍在开发中。
我想我一直遇到的问题都与Microsoft Graph仍在开发中有关,但是我想知道是否有人设法使其正常工作,以及他们是否可以为我指明正确的方向以进行身份验证设置并获得我开始将文件上传到OneDrive。
一些细节,以防万一:
非常感谢任何能为我指出正确方向的人:)
我正在使用oauth2 / token验证我的应用程序并获取access_token。贝娄是运行良好的Java代码。
private String getToken() throws Exception {
String access_token = "";
String url = "https://login.windows.net/MyApplication_ID_here/oauth2/token";
HttpClient client = HttpClients.createDefault();
HttpPost post = new HttpPost(url);
post.setHeader("Content-Type", "application/x-www-form-urlencoded");
List<NameValuePair> urlParameters = new ArrayList<NameValuePair>();
urlParameters.add(new BasicNameValuePair("grant_type", "client_credentials"));
urlParameters.add(new BasicNameValuePair("client_id", "MyApplication_ID_here"));
urlParameters.add(new BasicNameValuePair("client_secret", "MyApplication_secret_here"));
urlParameters.add(new BasicNameValuePair("resource", "https://graph.microsoft.com"));
post.setEntity(new UrlEncodedFormEntity(urlParameters));
HttpResponse response = client.execute(post);
System.out.println("Sending 'POST' request to URL : " + url);
System.out.println("Post parameters : " + post.getEntity());
System.out.println("Response Code : " + response.getStatusLine().getStatusCode());
String responseAsString = EntityUtils.toString(response.getEntity());
System.out.println(responseAsString);
try …
Run Code Online (Sandbox Code Playgroud) oauth-2.0 office365 azure-active-directory azure-ad-graph-api microsoft-graph
在尝试创建用于批量更新用户日历的deamon应用程序时,我偶然发现了以下文档:
由于您似乎可以在"不要将此API用于新项目API"中批量(也称合并)最多20个请求,但您最多只能使用新的Microsoft Graph API组合5个请求.
我发现没有批处理创建和删除100个日历项目大约需要40秒.由于应用程序管理变得如此简单,我想使用新的API,但是有没有任何更改,5请求批量限制将被删除,让我们说20就像旧的API一样?
我正在使用AzureAD模块创建一个Azure AD应用程序来调用Microsoft Graph API。我可以成功生成访问令牌。但是,当我尝试调用API时,出现错误“消息”:“无效的范围声明/角色。”。
当我在Azure门户中创建的应用程序中单击“授予权限”按钮并重试对API的调用时,该调用正在运行。
我在任何地方都找不到如何使用Powershell进行此“授予权限”操作。有没有办法做到这一点 ?
谢谢
达米安
使用Microsoft Graph API,我想通过名称或电子邮件地址查找房间,例如:
https://graph.microsoft.com/beta/me/findRooms?$filter=startswith(mail,'cal_')
Run Code Online (Sandbox Code Playgroud)
要么
https://graph.microsoft.com/beta/me/findRooms?$filter=startswith(name,'Building 1')
Run Code Online (Sandbox Code Playgroud)
我们的房间不在RoomLists,有超过100间客房.
如何查询特定房间或房间子集?
我的问题是,我们是否有任何记录方法向Graph API授予管理服务标识权限,就像在门户网站中使用Azure App注册一样?我无法在Azure门户或文档中找到任何Powershell选项或管理MSI服务主体权限的能力.我在MSDN论坛上发现了一个类似的问题,但是想确保没有任何人知道的更新或变通方法?
MSDN论坛帖子:https://social.msdn.microsoft.com/Forums/azure/en-US/dae34534-f193-4444-b52e-ba9cfa4a1fda/does-azure-msi-support-accessing-graph-api? forum = WindowsAzureAD
azure-active-directory microsoft-graph azure-managed-identity
如标题所述,是否有来自官方文档的sharepoint在线rest api的完整列表?
我做了一些研究。但是,从MS文档中,我只能找到使用SharePoint REST终结点的完整基本操作,并了解SharePoint REST服务。
或者,也许只有目前官方文档中没有REST API参考和示例的Sharepoint Online实现。
我也考虑过使用MS图,但是目前看来,与本机SharePoint REST API相比,Graph for SharePoint公开的操作非常有限。
如果有清单,请分享。
microsoft-graph ×10
office365 ×2
angular ×1
azure ×1
javascript ×1
oauth-2.0 ×1
office365api ×1
onedrive ×1
outlook ×1
powershell ×1
python ×1
rest ×1
sharepoint ×1