我正在按照本教程远程验证 Sharepoint Online,但我是在 C# 中进行的。
http://allthatjs.com/2012/03/28/remote-authentication-in-sharepoint-online/
我可以毫无问题地从 STS 获取 SAML,但我似乎无法将此令牌发送到 Sharepoint 以接收 Cookie 以便登录。下面是我的代码,请原谅任何明显的错误,我是新手!
 //Send cookie to SPO. The token is from STS.
        byte[] spbyteArray = Encoding.UTF8.GetBytes(theToken);
        WebRequest sprequest = WebRequest.Create("https://login.microsoftonline.com/login.srf?wa=wsignin1.0&rpsnv=2&ct=1335885737&rver=6.1.6206.0&wp=MBI&wreply=https%3A%2F%2Fcamida.sharepoint.com%2F_forms%2Fdefault.aspx&lc=1033&id=500046&cbcxt=mai&wlidp=1&guest=1");
        sprequest.Method = "POST";
        sprequest.ContentLength = spbyteArray.Length;
        sprequest.ContentType = "application/x-www-form-urlencoded";
        sprequest.Headers.GetType().InvokeMember("ChangeInternal", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod, null, sprequest.Headers, new object[] { "Host", "mydomain.sharepoint.com" });
        Stream spdataStream = sprequest.GetRequestStream();
        spdataStream.Write(spbyteArray, 0, spbyteArray.Length);
        spdataStream.Close();
        //Get response from SPO
        WebResponse spresponse = sprequest.GetResponse();
        spdataStream = spresponse.GetResponseStream();
        StreamReader spreader = new StreamReader(spdataStream);
        // Read the content.
        string spresponseFromServer = spreader.ReadToEnd();
如果我使用教程中的 URL,我会收到 403 禁止。我使用的 URL 是当我到达http://mydomain.sharepoint.com时它重定向到的 URL
非常感谢任何帮助和建议。