azure - Sharepoint REST api - 领域不是当前服务命名空间错误 50169 的配置领域
问题描述
我在尝试从 Sharepoint REST api 获取身份验证令牌时遇到此错误。我的 SP 是基于云的,我正在使用 Postman 来测试请求,因为之前的尝试同样陷入了死胡同,因为 Msoft 来回进行大量故障排除导致无处可去。无论如何,我有以下错误,我想知道是否任何人都可以帮助我弄清楚它是什么或如何解决这个问题。
error_description: "AADSTS50169: The realm 'realm' is not a configured realm of the current service namespace"
error_codes : 50169
谢谢!
编辑:我经历并重新开始,这个 tut 似乎正在工作我想我可能错过了一步(我的猜测是我在创建应用程序时没有使用 xml 正确配置应用程序权限)
解决方案
要通过 Postman 在线授权 SharePoint 并使用 REST API,这里有一个解决方案供您参考:
第一:获取安全Token
通过 Http Post 方法访问 [ https://login.microsoftonline.com/extSTS.srf] 。http请求的内容如下。
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"
xmlns:a="http://www.w3.org/2005/08/addressing"
xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-
utility-1.0.xsd">
<s:Header>
<a:Action
s:mustUnderstand="1">http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue</a:Action>
<a:ReplyTo>
<a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
</a:ReplyTo>
<a:To s:mustUnderstand="1">https://login.microsoftonline.com/extSTS.srf</a:To>
<o:Security s:mustUnderstand="1"
xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<o:UsernameToken>
<o:Username>[username]</o:Username>
<o:Password>[password]</o:Password>
</o:UsernameToken>
</o:Security>
</s:Header>
<s:Body>
<t:RequestSecurityToken xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust">
<wsp:AppliesTo xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
<a:EndpointReference>
<a:Address>[endpoint]</a:Address>
</a:EndpointReference>
</wsp:AppliesTo>
<t:KeyType>http://schemas.xmlsoap.org/ws/2005/05/identity/NoProofKey</t:KeyType>
<t:RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</t:RequestType>
<t:TokenType>urn:oasis:names:tc:SAML:1.0:assertion</t:TokenType>
</t:RequestSecurityToken>
</s:Body>
</s:Envelope>
Postman 中的演示截图:
并且响应内容将包含一个安全令牌,如下所示,我们可以使用这个安全令牌来获取 SharePoint 的访问令牌。
二:获取Access Token
在这里,我将向您展示如何使用安全令牌和 SharePoint Rest API 在线获取 SharePoint 的访问令牌。
通过 http Post 方法访问 [ https://yourdomain.sharepoint.com/_forms/default.aspx?wa=wsignin1.0] 。请求的内容是我们上面得到的安全令牌,如下所示。
响应如下:
我们可以看到响应头中有两个cookie,rtFa和FedAuth,这两个cookie需要在后续请求中添加到请求中。
第三:获取请求摘要
使用我们上面得到的两个 cookie 通过 http Post 方法访问 [ https://yourdomain.sharepoint.com/_api/contextinfo] 。
响应如下:
这是我们想要的最终代币!
然后我们就可以使用SharePoint的REST API了,我们只需要加上这个token和前面的两个cookie,如下图所示。
推荐阅读
- discord - webhook 和角色/权限概念的问题
- css - 反应中的可重用搜索组件-文本溢出时css失败
- r - PCA 分析:dim desc() 中出现错误:数据不方便
- meteor - 在 MeteorJS 中的表单上提交后路由到新 URL
- php - 在 Wordpress 中在一页上使用 PHP 更改永久链接
- java - 你怎么知道如何限制有多少客户端可以进入你的基本群聊应用服务器?(最多 10 个)
- hadoop - 由于输入字符串的 java.lang.NumberFormatException 导致 Apache Tez 作业失败:“30s”
- java - Java中的Chrome sqlite数据库Cookie过期转换
- python - 如何合并和求和 2 个嵌套字典的值并保留不存在的键:值对
- vb.net - ADO.NET:如何将 DataTable 中的行批量复制到另一个