title: How to get '.TokenAuthCookies' cookie from .docs.microsoft.com in ASP.NET Core MVC?
body: <p>Currently I am facing an issue with finding way to get cookie from '.docs.microsoft.com'. Please refer to the cookie details shown below.</p>
  <pre><code>Name: .TokenAuthCookies,
  Domain: .doc.microsoft.com,
  Path: /
  </code></pre>
  <p><a href="https://i.stack.imgur.com/oBHN9.png" rel="nofollow noreferrer">.TokenAuthCookies details</a></p>
  <p><strong>Optional details</strong></p>
  <p>My effort is to <a href="https://docs.microsoft.com/en-us/rest/api/resources/tenants/list#code-try-0" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/rest/api/resources/tenants/list#code-try-0</a> do the same as the this API doc do. To authenticate this API request first they get tenant array from <a href="https://token.docs.microsoft.com/accesstokens" rel="nofollow noreferrer">https://token.docs.microsoft.com/accesstokens</a> this URL. To authenticate that They are using cookie by the name of <code>.TokenAuthCookies</code> from the API request (<a href="https://token.docs.microsoft.com/accesstokens" rel="nofollow noreferrer">https://token.docs.microsoft.com/accesstokens</a>) cookie header.</p>
  <p><strong>Developed so far</strong></p>
  <p>I enabled the session inside the startup class' <code>Configure</code> method:</p>
  <pre><code>app.UseSession();
  </code></pre>
  <p>I tried to create customer cookie; I don't have experience on this before. Inside startup class' <code>ConfigureServices</code> method:</p>
  <pre><code>services.AddSession(options =&gt;
              {
                  options.IdleTimeout = TimeSpan.FromSeconds(40);
                  options.Cookie.Name = &quot;.TokenAuthCookies&quot;;
                  options.Cookie.Path = &quot;/&quot;;
                  options.Cookie.Domain = &quot;.docs.microsoft.com&quot;;
                  options.Cookie.IsEssential = true;
                  options.Cookie.SameSite = SameSiteMode.Unspecified;
              });
  </code></pre>
  <p>Inside controller, I need to put cookie value to here.</p>
  <pre><code>HttpContext.Session.TryGetValue(&quot;.TokenAuthCookies&quot;, out byte[] VALUE_BYTES);
             var value = VALUE_BYTES == null ? &quot;&quot; : Encoding.ASCII.GetString(VALUE_BYTES);
  
  var client = new RestClient(&quot;https://token.docs.microsoft.com/accesstokens&quot;);
                  client.Timeout = -1;
                  var request = new RestRequest(Method.POST);
                  
                  request.AddHeader(&quot;Cookie&quot;, value???);
                  IRestResponse response = client.Execute(request);
  </code></pre>
  <p>Please refer to this screenshot of my MS Docs api request overview:</p>
  <p><a href="https://i.stack.imgur.com/Mi3AJ.jpg" rel="nofollow noreferrer">Token API request overview</a></p>
  <p>I just need to know how to get <code>.TokenAuthCookies</code> cookie to my app and put it my controller API request 'cookie' header.</p>