質問編集履歴

2

現在のレスポンスの追記を行いました。

2017/10/26 05:47

投稿

chris_k
chris_k

スコア12

test CHANGED
File without changes
test CHANGED
@@ -77,3 +77,27 @@
77
77
  var res = await client.SendAsync(req);
78
78
 
79
79
  ```
80
+
81
+
82
+
83
+ 現在、レスポンス自体は返ってきておりますが
84
+
85
+ 以下の様な意図しない形式となっております。
86
+
87
+ > StatusCode: 400,
88
+
89
+ ReasonPhrase: ‘Bad Request’,
90
+
91
+ Version: 1.1,
92
+
93
+ Content: System.Net.Http.StreamContent,
94
+
95
+ Headers: {
96
+
97
+ Pragma: no-cache Strict-Transport-Security: max-age=31536000; includeSubDomains X-Content-Type-Options: nosniff x-ms-request-id: 1b5a4e18-428d-4fb5-a611-2e6856ff0800
98
+
99
+ Cache-Control: no-store, no-cache P3P: CP="DSP CUR OTPi IND OTRi ONL FIN" Set-Cookie: esctx=AQABAAAAAABHh4kmS_aKT5XrjzxRAtHz0bD6HfoCO6c1iY5rcV7Yv34N6jErn-UFuSw5FEUMBsNMZ1UgSZjrKClzkcztzIxzxiTCcny9c5ji8AIqda5wXfECjs6t1IpGT7j6aJRXR4mw8v9uPzAAmExtHnQ5wdMiHULc8XM9oBd8GDpPPs222T5oVYoRFzzljdV0-RdbA0kgAA;
100
+
101
+ domain=.login.microsoftonline.com; path=/; secure; HttpOnly Set-Cookie: x-ms-gateway-slice=008; path=/; secure; HttpOnly Set-Cookie: stsservicecookie=ests; path=/; secure; HttpOnly Server: Microsoft-IIS/8.5 X-Powered-By: ASP.NET Date: Thu, 26 Oct 2017 05:37:45 GMT Content-Length: 468 Content-Type: application/json; charset=utf-8 Expires: -1
102
+
103
+ }

1

現在の実装を追記いたしました。

2017/10/26 05:47

投稿

chris_k
chris_k

スコア12

test CHANGED
File without changes
test CHANGED
@@ -47,3 +47,33 @@
47
47
 
48
48
 
49
49
  よろしくお願いいたします。
50
+
51
+
52
+
53
+
54
+
55
+ ##### 追記事項
56
+
57
+ 現在実装しているコードを追記致します。
58
+
59
+ ```C#
60
+
61
+ string url = "https://login.microsoftonline.com/common/oauth2/token";
62
+
63
+ var nvc = new List<KeyValuePair<string, string>>();
64
+
65
+ nvc.Add(new KeyValuePair<string, string>("client_id", "3181129a-*******"));
66
+
67
+ nvc.Add(new KeyValuePair<string, string>("scope", "https://graph.microsoft.com/.default"));
68
+
69
+ nvc.Add(new KeyValuePair<string, string>("client_secret", "******************"));
70
+
71
+ nvc.Add(new KeyValuePair<string, string>("grant_type", "client_credentials"));
72
+
73
+ var client = new HttpClient();
74
+
75
+ var req = new HttpRequestMessage(HttpMethod.Post, url) { Content = new FormUrlEncodedContent(nvc) };
76
+
77
+ var res = await client.SendAsync(req);
78
+
79
+ ```