如何使用O365 API实现本机应用程序的管理员同意流程,其权限范围需要管理员同意?
经过数小时的谷歌搜索,阅读MS文档和代码示例,我现在更加困惑,需要一些架构建议.
基本上我需要弄清楚哪些API适用以及如何从它们开始.
我有一个现有的应用程序(目前是一个XAML + c#win store 8.1应用程序),带有一个WebAPI 2.2 odata(以及一些MVC页面)后端.
客户端应用程序在Win 8.1上运行良好并赢得10台机器服务器端位于天蓝色VM中.
目前
例如
_loginResult.Session.AuthenticationToken
Run Code Online (Sandbox Code Playgroud)
例如
LiveAuthClient authClient = new LiveAuthClient(clientId, clientSecret, redirectUrl);
string liveIdGuidAsString = authClient.GetUserId(authenticationToken);
Run Code Online (Sandbox Code Playgroud)
一切都很好.
似乎这些天要做到这一点的合理方法是使用
MS似乎也可能随时关闭我正在使用的Live API?
https://msdn.microsoft.com/en-us/library/hh243641.aspx
额外的复杂性
我也(在几个月的时间内)想要将应用程序扩展到
这意味着我希望在可能的情况下将其作为"原始OAuth"以实现兼容性,而不是将自己绑定到任何特定的MS API(显然,outlook/outlook.com日历集成只是具有MS帐户的用户可用的功能)
此外,一些现有用户拥有outlook.com帐户(他们用来登录Windows)但在Hosted Exchange 2010中拥有他们的日历数据
似乎要访问此日历数据,这些用户必须将所有Outlook 2016数据移至outlook.com,或将其设置为office 365帐户并将数据迁移到新帐户.
1.我应该在何处/与谁进行身份验证以获取我的授权码和访问令牌 - MS Graph?或Outlook REST API
我已经看到了这个答案(即基本上更喜欢MS …
office365 live-sdk azure-active-directory auth0 microsoft-graph
我正在尝试使用Microsoft Graph API检索在Azure AD门户上为我的租户创建的策略.据我从图API文档中了解,所有策略CRUD操作都需要Directory.AccessAsUser.All的范围.
此范围转换为权限Access目录作为登录用户,如此处所述 - https://developer.microsoft.com/en-us/graph/docs/authorization/permission_scopes
我一直在尝试在新的Azure门户和具有不同故障点的旧门户上配置我的应用程序.
在新门户网站上:
我已按照https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal上的说明在我的租户中创建了一个Web应用程序.
配置访问控制时,我的租户的唯一订阅是访问Azure Active Directory,我无法在新门户中为此配置访问控制.从浏览器中,当我选择访问控制(IAM)时,我看到错误 - "调用ARM失败,httpCode = BadRequest,errorCode = DisallowedOperation,message =当前订阅类型不允许对任何提供程序命名空间执行操作.请使用不同的订阅.,reason = Bad Request." "添加"角色按钮也被禁用.
我是否可以在订阅Access Active Directory上配置Access控件?如果是这样,是否没有其他方法可以使用API检索我的租户的策略?
在旧门户网站上:
对于我的应用,我配置了以下权限:
Microsoft Graph
Windows Azure Active Directory
Run Code Online (Sandbox Code Playgroud)
我在门户网站上验证了两个API都使用权限Access目录配置为登录用户.即使在这种情况下,当我尝试访问https://graph.microsoft.com/beta/policies端点以列出我的租户上的策略时,我仍然会收到403 Forbidden .
这是我获取的访问令牌上的有效负载(https://login.microsoftonline.com/ { my tenant name}/oauth2/token)
{
"aud": "https://graph.microsoft.com",
"iss": "https://sts.windows.net/8b49696d-462a-4a71-9c5c-f570b2222727/",
"iat": 1491256764,
"nbf": 1491256764,
"exp": 1491260664,
"aio": "Y2ZgYAi68q2XUTk0ykH7/TZzrhYbAA==",
"app_displayname": "test-app",
"appid": "951bb92d-5b68-45ae-bb8b-d768b2696ccc", …
Run Code Online (Sandbox Code Playgroud) Microsoft Graph API错误地将Word doc文件附件作为从/ me/messages端点返回的消息实体返回.
重现的场景如下:
向您自己发送一封包含一个或多个Word doc文件附件的电子邮件(或让其他人向您发送电子邮件)
在Graph Explorer中运行以下查询:https://graph.microsoft.com/v1.0/me/messages
请注意,将有一个对象代表电子邮件本身(这是正确的行为)和一个或多个对象,它们是文件附件的表示.
微软的某个人可以尽快与我联系吗?这是API中的一个主要错误,可能会导致大多数使用它的应用程序出现问题.
PS此问题之前已经提出并修复,但它已经重新开始了... 文件附件在Microsoft Graph API中显示为消息实体
我是否还建议围绕此问题编写一些自动化测试以防止它在将来再次发生?
我正在尝试对Microsft Graph进行基本调用。
https://graph.microsoft.com/v1.0/me/
我已经通过C#SDK并直接使用rest和两个调用来完成此操作,但出现以下错误
消息=“资源'f9d58168-4b3e-4948-9133-6c978d1ab18a'不存在,或者其查询的参考属性对象之一不存在。”
错误响应内容流中返回的完整错误消息
{
"error": {
"code": "Request_ResourceNotFound",
"message": "Resource 'f9d58168-4b3e-4948-9133-6c978d1ab18a' does not exist or one of its queried reference-property objects are not present.",
"innerError": {
"request-id": "80af6aec-5052-49ab-890c-273fea5c65ba",
"date": "2017-07-31T06:08:37"
}
}
}
Run Code Online (Sandbox Code Playgroud)
GUID可以不同。
当我通过“图形资源管理器”执行此操作时,它工作正常。
这是我用来获取应用程序凭据的代码
private ClientCredential GetCredentials()
{
return new ClientCredential(_azureAdOptions.ClientId, _azureAdOptions.ClientSecret);
}
private AuthenticationContext GetContext(string userObjectId)
{
return new AuthenticationContext($"{_azureAdOptions.AadInstance}{_azureAdOptions.Tenant}", GetTokenCache(userObjectId));
}
private DistributedTokenCache GetTokenCache(string userObjectId)
{
return new DistributedTokenCache(userObjectId, _azureAdOptions.ClientId, _distributedCache, _loggerFactory);
}
public async Task<AuthenticationResult> GetToken(string userObjectId, string resourceId)
{
AuthenticationResult result; …
Run Code Online (Sandbox Code Playgroud) 当我们获取特定客户的oAuth2 grants(beta/<tenant_id>/oAuth2Permissiongrants
)时,我们只获得3个授权,每个授予一个空范围:
[{
"consentType": "AllPrincipals",
"resourceId": "xxxxxxx-b2e2-42d8-9586-21aa24c78412",
"expiryTime": "2017-08-27T10:19:35.8989022Z",
"principalId": None,
"clientId": "xxxxxxx-bd4a-4ac5-ad18-ee304693a3ee",
"startTime": "2016-02-27T10:19:35.8989022Z",
"scope": "",
"id": "xxxxxxxxxx4wRpOj7nrF0zXisthClYYhqiTHhBI"
}, {
"consentType": "AllPrincipals",
"resourceId": "xxxxxxxx-b2e2-42d8-9586-21aa24c78412",
"expiryTime": "2018-03-01T15:16:24.8088543Z",
"principalId": None,
"clientId": "xxxxxxxx-633d-4f27-9d07-fe3f95aaa41c",
"startTime": "2016-09-01T15:16:24.8088543Z",
"scope": "",
"id": "xxxxxxxx-dB_4_laqkHHrF0zXisthClYYhqiTHhBI"
}, {
"consentType": "AllPrincipals",
"resourceId": "xxxxxxx-b2e2-42d8-9586-21aa24c78412",
"expiryTime": "2017-12-13T15:30:31.8853053Z",
"principalId": None,
"clientId": "xxxxxxxx-c2a8-4f2d-92d5-f4e41f82ad4c",
"startTime": "2016-06-13T15:30:31.8853053Z",
"scope": "",
"id": "xxxxxxxxx-S1fTkH4KtTHrF0zXisthClYYhqiTHhBI"
}]
Run Code Online (Sandbox Code Playgroud)
我们确信这个客户应该有几十个oAuth2拨款,我们期望在API响应中看到这些拨款.
可能是什么原因?
在阅读Microsoft文档后,我确定可以使用OData查询参数过滤组成员,因为https://developer.microsoft.com/zh-cn/graph/docs/api-reference/v1.0/api/group_list_members
请求GET URL- https: //graph.microsoft.com/v1.0/groups/ {groupId} / members?filter = startswith(givenname,'V')
在上面的URL中,从https://graph.microsoft.com/v1.0/groups使用了groupId
但是,当我尝试使用工作帐户登录名使用Graph Explorer(https://developer.microsoft.com/en-us/graph/graph-explorer)获取结果时,它不起作用。
我也尝试在SDK中使用它(我已经使用Microsoft graph API SDK在我的代码中实现了graph API),但仍然遇到相同的错误。
并给出以下错误-
{“错误”:{“代码”:“ Request_UnsupportedQuery”,“消息”:“当前不支持对参考属性查询的指定过滤器。”,“ innerError”:{“ request-id”:“ 96f3ffef-56f5- 42e3-82f2-64813106b729“,” date“:” 2018-02-13T10:59:39“}}}
这是因为“成员”不是资源类型吗?所以它没有属性,所以我们不能过滤此结果?
如果是这样,那么还有其他方法可以获取已过滤的组成员吗?
在Github上也发布了问题-https: //github.com/microsoftgraph/microsoft-graph-docs/issues/2239
我在Web浏览器中使用以下方法来使用Microsoft Graph获取DriveItem的文件内容:
GET /drives/{drive-id}/items/{item-id}
// Get the @microsoft.graph.downloadUrl property of the returned DriveItem
GET {downloadUrl}
Run Code Online (Sandbox Code Playgroud)
这需要两个GET
电话。
我也知道这个API:
GET /drives/{drive-id}/items/{item-id}/content
Run Code Online (Sandbox Code Playgroud)
如此处记录:
但是/content
端点有两个问题:
如何在一个请求中获取DriveItem的文件内容?
使用Microsoft Graph API v1(例如,向组中添加用户)对Azure AD中的组进行更改后,如果在更改后立即触发Group Delta Query,则图形delta查询不会返回相反,预期的delta必须在一段时间后再次执行Group delta查询以获得预期的更改.
使用Microsoft Graph API进行任何变异操作之间的预期延迟是什么,并因此在Delta Query的结果中获得相同的更改?
通过委派权限获取团队频道消息时(用户是团队的成员):
https://graph.microsoft.com/beta/teams/ {team_id} / channels / {channel_id} / messages /
出现错误:
{
"error": {
"code": "Proxy_InternalServerError",
"message": "Failure in forwarding request.",
"innerError": {
"request-id": "511b812c-df43-402b-b9dd-34ca1c1bd397",
"date": "2019-02-01T14:22:50"
}
}
Run Code Online (Sandbox Code Playgroud)
经过Graph Explorer和代码测试。
它对任何人有用吗?
microsoft-graph ×10
office365 ×3
auth0 ×1
javascript ×1
live-sdk ×1
office365api ×1
onedrive ×1