0

我正在尝试从 Dynamics CRM 2013 插件对 Sharepoint 2013 进行身份验证,所有这些都在单个 Office 365 环境中进行。我最终试图将电子邮件附件从 Dynamics CRM 复制到 Sharepoint(发布电子邮件附件创建异步)。到目前为止,这个旅程充满了障碍。

  • 我已经到 AppRegNew.aspx 获取客户端 ID 和密码。
  • 我已经建立了一个 Web 请求并将信息发布到 mycompanyname.sharepoint.com/_layouts/15/OAuthAuthorize.aspx但收到 403 Forbidden 错误。
  • 我无法使用 CSOM,因为我无法将 Sharepoint.Client.dll 部署到 Dynamics CRM Online
  • 我不确定请求参数中的范围应该是什么

这是我到目前为止的代码摘录:

string clientId = "myclientid";
string clientSecret = "asecretstring";

this.request = string.Format("grant_type=client_credentials&client_id={0}&client_secret={1}&scope=list.read", Uri.EscapeDataString(clientId), Uri.EscapeDataString(clientSecret));

WebRequest webRequest = WebRequest.Create(OAuthUri);
webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.Method = "POST";
byte[] bytes = Encoding.ASCII.GetBytes(this.request);
webRequest.ContentLength = bytes.Length;
using (Stream outputStream = webRequest.GetRequestStream())
{
    outputStream.Write(bytes, 0, bytes.Length);
}
using (WebResponse webResponse = webRequest.GetResponse())
{
    // get token from the response
}

我真的很感激在两个 Office 365 系统之间进行身份验证的一些方向。

4

1 回答 1

0

您还需要像这样设置 UserAgent 字符串 - “Mozilla/5.0(兼容;MSIE 9.0;Windows NT 6.1;WOW64;Trident/5.0)”

于 2015-03-08T21:30:35.667 回答