私はこれに少し夢中になっています..Windowsストアアプリケーションのsharepointオンラインサイトに対してクレーム認証が機能しています。しかし、Windows Phone 8 アプリのまったく同じコードは機能しません。1 つの違いは、System.Net.Http-namespace は Windows Phone の Nuget パッケージとしてのみ利用できることです。
認証プロセスでは、最初に HttpRequest を Microsoft に送信して、STS Saml トークンを取得します。次に、このトークンを 2 番目の HttpRequest と共に sharepoint オンライン サイトに送信して、認証 Cookie (FedAuth / rtFA) を取得します。
Windows ストア アプリ STA Saml トークン:
HttpRequestMessage {Method: POST, RequestUri: https://login.microsoftonline.com/extSTS.srf', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Accept: application/soap+xml; charset=utf-8
Content-Type: application/soap+xml; charset=utf-8
Content-Length: 1335
}} System.Net.Http.HttpRequestMessage
HttpResponse {StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Pragma: no-cache
X-XSS-Protection: 0
PPServer: PPV: 30 H: CO1IDOALGN08 V: 0
Connection: close
Cache-Control: no-cache
Date: Tue, 29 Oct 2013 07:52:18 GMT
P3P: CP="DSP CUR OTPi IND OTRi ONL FIN"
Server: Microsoft-IIS/7.5
Content-Length: 3661
Content-Type: application/soap+xml; charset=utf-8
Expires: Tue, 29 Oct 2013 07:51:18 GMT
}} System.Net.Http.HttpResponseMessage
HttpResponse.Content {byte[3661]} byte[]
Windows ストア アプリの SPOAuthToken:
HttpRequestMessage {Method: POST, RequestUri: 'https://xxx.sharepoint.com/SitePages/Startsida.aspx', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Accept: application/x-www-form-urlencoded
Content-Type: application/x-www-form-urlencoded
Content-Length: 893
}} System.Net.Http.HttpRequestMessage
HttpResponse {StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
X-SharePointHealthScore: 0
SPRequestGuid: 0556519c-19a2-20e0-a937-44fc861d2ddc
request-id: 0556519c-19a2-20e0-a937-44fc861d2ddc
X-FRAME-OPTIONS: SAMEORIGIN
SPRequestDuration: 742
SPIisLatency: 1
MicrosoftSharePointTeamServices: 16.0.0.2120
X-Content-Type-Options: nosniff
X-MS-InvokeApp: 1; RequireReadOnly
Cache-Control: max-age=0, private
Date: Tue, 29 Oct 2013 07:52:57 GMT
P3P: CP="ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI"
Set-Cookie: 8167acc39dff40bf855ec089c80b8fbc2ca28f1fc09f48f5ad16ab2bd0e6ee02i%3A0%23%2Ef%7Cmembership%7Crobert%40portalplus%2Ese=0; expires=Wed, 30-Oct-2013 07:52:57 GMT; path=/; HttpOnly
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Content-Length: 107958
Content-Type: text/html; charset=utf-8
Expires: Mon, 14 Oct 2013 07:52:56 GMT
Last-Modified: Tue, 29 Oct 2013 07:52:56 GMT
}} System.Net.Http.HttpResponseMessage
HttpResponse.Content {byte[107958]} byte[]
Windows Phone アプリ STA Saml トークン:
HttpRequestMessage {Method: POST, RequestUri: 'https://login.microsoftonline.com/extSTS.srf', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Accept: application/soap+xml; charset=utf-8
Content-Type: application/soap+xml; charset=utf-8
Content-Length: 1335
}} System.Net.Http.HttpRequestMessage
HttpResponse {StatusCode: 200, ReasonPhrase: 'OK', Version: 0.0, Content: System.Net.Http.StreamContent, Headers:
{
Cache-Control: no-cache
Pragma: no-cache
Server: Microsoft-IIS/7.5
P3P: CP="DSP CUR OTPi IND OTRi ONL FIN"
X-XSS-Protection: 0
PPServer: PPV: 30 H: CO1IDOLGN56 V: 0
Date: Tue, 29 Oct 2013 07:50:25 GMT
Connection: close
Content-Length: 3661
Content-Type: application/soap+xml; charset=utf-8
Expires: Tue, 29 Oct 2013 07:49:26 GMT
}} System.Net.Http.HttpResponseMessage
HttpResponse.Content {byte[3661]} byte[]
Windows Phone アプリ SPOAuthToken で:
HttpRequestMessage {Method: POST, RequestUri: 'https://xxx.sharepoint.com/SitePages/Startsida.aspx', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Accept: application/x-www-form-urlencoded
Content-Type: application/x-www-form-urlencoded
Content-Length: 893
}} System.Net.Http.HttpRequestMessage
HttpResponse {StatusCode: 200, ReasonPhrase: 'OK', Version: 0.0, Content: System.Net.Http.StreamContent, Headers:
{
Cache-Control: max-age=0, private
Server: Microsoft-IIS/7.5
X-SharePointHealthScore: 0
X-AspNet-Version: 4.0.30319
SPRequestGuid: ef55519c-0917-20e0-6056-033a05a409d8
request-id: ef55519c-0917-20e0-6056-033a05a409d8
X-FRAME-OPTIONS: SAMEORIGIN
SPRequestDuration: 1289
SPIisLatency: 0
X-Powered-By: ASP.NET
MicrosoftSharePointTeamServices: 16.0.0.2120
X-Content-Type-Options: nosniff
X-MS-InvokeApp: 1; RequireReadOnly
P3P: CP="ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI"
Date: Tue, 29 Oct 2013 07:51:25 GMT
Content-Length: 107956
Content-Type: text/html; charset=utf-8
Expires: Mon, 14 Oct 2013 07:51:24 GMT
Last-Modified: Tue, 29 Oct 2013 07:51:24 GMT
}} System.Net.Http.HttpResponseMessage
HttpResponse.Content {byte[107956]} byte[]
私が見る違いは
- 回答: WS のバージョン 1.1 ではなく WP のバージョン 0.0
- WP8 の応答に Set-Cookie がありません (根本的なエラー)
- SPO Cookie WS の ResponseContent は WP8 より 2 バイト大きい
彼らが「電話を離れる」前に何らかの形でhttpリクエストを無効にするWP8に何かがありますか? どんなアイデアでも大歓迎です。
編集:WP8 OSが原因であると確信しています。認証コードをポータブル ライブラリに移動したので、両方のプラットフォームからまったく同じコードを実行できます。それでも、ストアアプリだけが機能します!そして、奇妙なことは続きます.エミュレータではなく実際の電話でデバッグモードで実行すると、Cookieを取得します.
しかし、WP で実行される移植可能なコードでは、Cookie は CookieContainer に異なる方法で格納されるため、Cookie を実際に使用して SharePoint からデータを取得することはまだできていません...頭が痛いです。
結論: Windows Phone OS は、Microsoft/SP から生の Cookie データを実際に取得するため、おそらく受信側でデータに対して奇妙なことを行います。Windows 8 とは異なるように見えるのは、これがポータブル コードに組み込まれたときです。
EDIT2 : さらに調査すると、クライアント側で Cookie を配置するために使用される CookieContainer の動作が異なることがわかります。
Cookie がコンテナに追加された後、WP8 では空ですが、W8 から実行すると自分のドメインが含まれるプライベート文字列「m_fqdnMyDomain」があります。GetCookies(uri) は WP8 では何も返しませんが (Add(uri, cookie) で追加しただけでも)、W8 では正しく返します。これはすべて、両方の環境で実行される同じ移植可能なコードで行われます。