<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Using Cookies in Power Query(M) in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Using-Cookies-in-Power-Query-M/m-p/1433301#M26119</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/264323"&gt;@PhilipTreacy&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my Code which has just the OAuth logic and the Cookies method:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;//&lt;BR /&gt;// OAuth configuration settings&lt;BR /&gt;//&lt;BR /&gt;username=Json.Document(Extension.Contents("source.json")) [source][username];&lt;BR /&gt;password=Json.Document(Extension.Contents("source.json")) [source][password];&lt;BR /&gt;client_id = Json.Document(Extension.Contents("source.json")) [source][client_id];&lt;BR /&gt;redirect_uri = Json.Document(Extension.Contents("source.json")) [source][redirect_uri];&lt;BR /&gt;token_uri = Json.Document(Extension.Contents("source.json")) [source][token_uri];&lt;BR /&gt;authorize_uri = Json.Document(Extension.Contents("source.json")) [source][authorize_uri];&lt;BR /&gt;logout_uri = Json.Document(Extension.Contents("source.json")) [source][logout_uri];&lt;/P&gt;&lt;P&gt;windowWidth = 1000;&lt;BR /&gt;windowHeight = 1024;&lt;/P&gt;&lt;P&gt;scope_prefix = "&lt;A href="https://graph.microsoft.com/" target="_blank"&gt;https://graph.microsoft.com/&lt;/A&gt;";&lt;BR /&gt;scopes = {&lt;BR /&gt;"User.Read",&lt;BR /&gt;"openid"&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;// Helper Functions&lt;BR /&gt;Value.IfNull = (a, b) =&amp;gt; if a &amp;lt;&amp;gt; null then a else b;&lt;/P&gt;&lt;P&gt;GetScopeString = (scopes as list, optional scopePrefix as text) as text =&amp;gt;&lt;BR /&gt;let&lt;BR /&gt;prefix = Value.IfNull(scopePrefix, ""),&lt;BR /&gt;addPrefix = List.Transform(scopes, each prefix &amp;amp; _),&lt;BR /&gt;asText = Text.Combine(addPrefix, " ")&lt;BR /&gt;in&lt;BR /&gt;asText;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;// Data Source definition. OAuth Process:&lt;BR /&gt;Software = [&lt;BR /&gt;TestConnection = (dataSourcePath) =&amp;gt; { "Software.Contents" },&lt;BR /&gt;Authentication = [&lt;BR /&gt;OAuth = [&lt;BR /&gt;StartLogin=StartLogin,&lt;BR /&gt;FinishLogin=FinishLogin,&lt;BR /&gt;Refresh=Refresh,&lt;BR /&gt;Logout=Logout&lt;BR /&gt;]&lt;BR /&gt;],&lt;BR /&gt;Label = "Software Connector"&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;StartLogin = (resourceUrl, state, display) =&amp;gt;&lt;BR /&gt;let&lt;BR /&gt;authorizeUrl = authorize_uri &amp;amp; "?" &amp;amp; Uri.BuildQueryString([&lt;BR /&gt;client_id = client_id,&lt;BR /&gt;redirect_uri = redirect_uri,&lt;BR /&gt;state = state,&lt;BR /&gt;scope = "offline_access " &amp;amp; GetScopeString(scopes, scope_prefix),&lt;BR /&gt;response_type = "code",&lt;BR /&gt;response_mode = "query",&lt;BR /&gt;login = "login"&lt;BR /&gt;])&lt;BR /&gt;in&lt;BR /&gt;[&lt;BR /&gt;LoginUri = authorizeUrl,&lt;BR /&gt;CallbackUri = redirect_uri,&lt;BR /&gt;WindowHeight = 720,&lt;BR /&gt;WindowWidth = 1024,&lt;BR /&gt;Context = null&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;FinishLogin = (context, callbackUri, state) =&amp;gt;&lt;BR /&gt;let&lt;BR /&gt;// parse the full callbackUri, and extract the Query string&lt;BR /&gt;parts = Uri.Parts(callbackUri)[Query],&lt;BR /&gt;// if the query string contains an "error" field, raise an error&lt;BR /&gt;// otherwise call TokenMethod to exchange our code for an access_token&lt;BR /&gt;result = if (Record.HasFields(parts, {"error", "error_description"})) then&lt;BR /&gt;error Error.Record(parts[error], parts[error_description], parts)&lt;BR /&gt;else&lt;BR /&gt;TokenMethod("authorization_code", "code", parts[code])&lt;BR /&gt;in&lt;BR /&gt;result;&lt;/P&gt;&lt;P&gt;// Called when the access_token has expired, and a refresh_token is available.&lt;BR /&gt;Refresh = (resourceUrl, refresh_token) =&amp;gt; TokenMethod("refresh_token", "refresh_token", refresh_token);&lt;/P&gt;&lt;P&gt;Logout = (token) =&amp;gt; logout_uri;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;TokenMethod = (grantType, tokenField, code) =&amp;gt;&lt;BR /&gt;let&lt;BR /&gt;queryString = [&lt;BR /&gt;client_id=client_id,&lt;BR /&gt;scope= Json.Document(Extension.Contents("Source.json")) [source] [scope],&lt;BR /&gt;grant_type="password",&lt;BR /&gt;response_type="token",&lt;BR /&gt;username=username,&lt;BR /&gt;password=password&lt;BR /&gt;],&lt;BR /&gt;queryWithCode = Record.AddField(queryString, tokenField, code),&lt;/P&gt;&lt;P&gt;tokenResponse = Web.Contents(token_uri, [&lt;BR /&gt;Content = Text.ToBinary(Uri.BuildQueryString(queryWithCode)),&lt;BR /&gt;Headers = [&lt;BR /&gt;#"Content-type" = "application/x-www-form-urlencoded",&lt;BR /&gt;#"Accept" = "application/json"&lt;BR /&gt;],&lt;BR /&gt;ManualStatusHandling = {400}&lt;BR /&gt;]),&lt;BR /&gt;body = Json.Document(tokenResponse),&lt;BR /&gt;result = if (Record.HasFields(body, {"error", "error_description"})) then&lt;BR /&gt;error Error.Record(body[error], body[error_description], body)&lt;BR /&gt;else&lt;BR /&gt;body&lt;BR /&gt;&lt;BR /&gt;in&lt;BR /&gt;result;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;[DataSource.Kind="SoftwareConnector", Publish="Software.Publish"]&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;shared Software.Contents = (url as text) =&amp;gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;let&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;source = Json.Document(Web.Contents(url))&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;in&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;source;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;//Get the tenant Cookie&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;GetCookies = (url as text) =&amp;gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;let &lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;CookieResponse = Web.Contents("https://domain/CloudAssessmentService/api/cookie", [Headers = [#"Authorization"= "Bearer " &amp;amp; "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIm......", #"Content-Type" = "application/json"]])//////////////HARDCODED TOKEN//////////&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;in&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;CookieResponse;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;TryToken = () =&amp;gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;let &lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;GetSoftwareAccessToken = TokenMethod,&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;HTTPHeader = [Headers = [#"Authorization"= "Bearer " &amp;amp; GetSoftwareAccessToken, #"Content-Type" = "application/json"]],&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;CookieRequest = WebMethod.Get(Web.Contents("https://domain/CloudAssessmentService/api/cookie", HTTPHeader))/////////////DYNAMIC TOKEN BASED ON THE TOKEN METHOD//////////////////&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;in &lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;CookieRequest;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//&lt;BR /&gt;// Exported function(s)&lt;BR /&gt;//&lt;/P&gt;&lt;P&gt;Software.Publish = [&lt;BR /&gt;Beta = true,&lt;BR /&gt;ButtonText = { "Software.Contents", "Connect to Software" },&lt;BR /&gt;SourceImage = Software.Icons,&lt;BR /&gt;SourceTypeImage = Software.Icons&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;Software.Icons = [&lt;BR /&gt;Icon16 = { Extension.Contents("Software16.png"), Extension.Contents("Software20.png"), Extension.Contents("Software24.png"), Extension.Contents("Software32.png") },&lt;BR /&gt;Icon32 = { Extension.Contents("Software32.png"), Extension.Contents("Software40.png"), Extension.Contents("Software48.png"), Extension.Contents("Software64.png") }&lt;BR /&gt;];&lt;/P&gt;&lt;BR /&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I've highlighted Cookies functions and also the Data Source description as I'm now confused if I should call these cookies functions explicitly somewhere or in the Data Source description.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 14 Oct 2020 12:54:19 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2020-10-14T12:54:19Z</dc:date>
    <item>
      <title>Using Cookies in Power Query(M)</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Using-Cookies-in-Power-Query-M/m-p/1421753#M26038</link>
      <description>&lt;P&gt;&lt;FONT size="2"&gt;Hi Team&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;I need some help in working with cookies. Flow is:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;1. I will use the OAuth flow to get the access token(I'm getting it)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;2. Use this token and hit our cookie url using the GET method(https://domain/CurrentAssessment/api/cookie)&amp;nbsp;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;I'm getting the access_token successfully but I'm not able to use it to send it to our cookie url. I've tried a lot of different ways and researched online but haven't had any success. Please note the token method below:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;TokenMethod = (grantType, tokenField, code) =&amp;gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;let&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;queryString = [&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;client_id=client_id,&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;scope= Json.Document(Extension.Contents("Source.json")) [source] [scope], &lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;grant_type="password",&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;response_type="token",&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;username=username,&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;password=password &lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;],&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;queryWithCode = Record.AddField(queryString, tokenField, code),&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;tokenResponse = Web.Contents(token_uri, [&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;Content = Text.ToBinary(Uri.BuildQueryString(queryWithCode)),&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;Headers = [&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;#"Content-type" = "application/x-www-form-urlencoded",&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;#"Accept" = "application/json"&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;],&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;ManualStatusHandling = {400} &lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;]),&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;body = Json.Document(tokenResponse),&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;result = if (Record.HasFields(body, {"error", "error_description"})) then &lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;error Error.Record(body[error], body[error_description], body)&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;else &lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;body&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;in&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;result;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;FONT size="2"&gt;I would appreciate any suggestions/help on this. Here is my powershell code which has the cookie method if it helps:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;#Get the tenant cookie&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;$cookieResponse = Invoke-WebRequest -Method Get -Uri "https://$cloudUrl/CurrentAssessment/api/cookie" -Headers $requestHeaders -SessionVariable cookieSession -UseBasicParsing&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;$tenantCookie = $cookieSession.Cookies.GetCookies("https://$cloudUrl") | where Name -eq "CurrentAssessment"&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Oct 2020 15:29:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Using-Cookies-in-Power-Query-M/m-p/1421753#M26038</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-10-08T15:29:07Z</dc:date>
    </item>
    <item>
      <title>Re: Using Cookies in Power Query(M)</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Using-Cookies-in-Power-Query-M/m-p/1428738#M26085</link>
      <description>&lt;P&gt;I would appreciate if someone could share their valuable inputs.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Oct 2020 18:20:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Using-Cookies-in-Power-Query-M/m-p/1428738#M26085</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-10-12T18:20:06Z</dc:date>
    </item>
    <item>
      <title>,Re: Using Cookies in Power Query(M)</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Using-Cookies-in-Power-Query-M/m-p/1429317#M26090</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How does the API tell you to use the token to GET&amp;nbsp;&lt;SPAN&gt;&lt;A href="https://domain/CurrentAssessment/api/cookie?" target="_blank"&gt;https://domain/CurrentAssessment/api/cookie?&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;What have you tried that hasn't worked?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Which API are you trying to access?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Phil&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Oct 2020 04:33:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Using-Cookies-in-Power-Query-M/m-p/1429317#M26090</guid>
      <dc:creator>PhilipTreacy</dc:creator>
      <dc:date>2020-10-13T04:33:34Z</dc:date>
    </item>
    <item>
      <title>Re: ,Re: Using Cookies in Power Query(M)</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Using-Cookies-in-Power-Query-M/m-p/1429355#M26093</link>
      <description>&lt;P&gt;Hi Phil&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the reply.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To complete the authorization process, we need to get the access token first and then send it to our cookie url so that we can hit our cloud APIs. &lt;STRONG&gt;I have got this working in Postman&lt;/STRONG&gt;. Unfortunately, I'm not able to get the cookies part working in my M code. I have tried many different ways but haven't got throught yet. Example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;BR /&gt;&lt;P&gt;TryCookie = () =&amp;gt;&lt;BR /&gt;let&lt;BR /&gt;GetSoftwareAccessToken = TokenMethod,&lt;BR /&gt;HTTPHeader = [Header = [#"Authorization"= "Bearer " &amp;amp; GetSoftwareAccessToken , #"Content-Type" = "application/json"]],&lt;BR /&gt;CookieRequest = Web.Contents("https://domain/CloudAssessmentService/api/cookie", HTTPHeader)&lt;BR /&gt;in&lt;BR /&gt;CookieRequest;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Oct 2020 05:21:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Using-Cookies-in-Power-Query-M/m-p/1429355#M26093</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-10-13T05:21:12Z</dc:date>
    </item>
    <item>
      <title>Re: Using Cookies in Power Query(M)</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Using-Cookies-in-Power-Query-M/m-p/1432172#M26111</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You haven't said how you are supposed to GET the cookie.&amp;nbsp; I don't know what API you are working with or how it expects the request to be formed.&amp;nbsp; Can you share the documentation.&lt;/P&gt;&lt;P&gt;Can you share what you did in Postman that worked.&lt;/P&gt;&lt;P&gt;What error are you getting in PQ?&lt;/P&gt;&lt;P&gt;Note: the keyword is &lt;STRONG&gt;Headers&lt;/STRONG&gt;, not &lt;STRONG&gt;Header&lt;/STRONG&gt; i.e.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="php"&gt;HTTPHeader = [Headers = [#"Authorization"= "Bearer " &amp;amp; GetSoftwareAccessToken , #"Content-Type" = "application/json"]]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Phil&lt;/P&gt;</description>
      <pubDate>Wed, 14 Oct 2020 06:19:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Using-Cookies-in-Power-Query-M/m-p/1432172#M26111</guid>
      <dc:creator>PhilipTreacy</dc:creator>
      <dc:date>2020-10-14T06:19:26Z</dc:date>
    </item>
    <item>
      <title>Re: Using Cookies in Power Query(M)</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Using-Cookies-in-Power-Query-M/m-p/1432314#M26112</link>
      <description>&lt;P&gt;Hi Phil&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately, we don't have an API document that even I could have referred to. However, here is the process that works in Postman. I have saved the below details in a text file as curlcommand:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;curl --location --request POST 'https://domain/domain.onmicrosoft.com/oauth2/v2.0/token' \&lt;BR /&gt;--header 'Content-Type: application/x-www-form-urlencoded' \&lt;BR /&gt;--form 'client_id=value' \&lt;BR /&gt;--form 'scope=value' \&lt;BR /&gt;--form 'grant_type=password' \&lt;BR /&gt;--form 'response_type=token' \&lt;BR /&gt;--form 'username=value' \&lt;BR /&gt;--form 'password=value'&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;1. I will import this text file in the postman and send a POST request which will return the Access_Token and Refresh_Token.&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Copy that Access_Token and under Authorization select Bearer token as an option and paste the Access_token.&lt;/P&gt;&lt;P&gt;3. Now change the URL from the access token url(https://domain/domain.onmicrosoft.com/oauth2/v2.0/token) to our Cookie url(&lt;SPAN&gt;https://domain/CloudAssessmentService/api/cookie&lt;/SPAN&gt;) and the method from POST to GET and hit send to get the Cookies.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;This completes my authorization.&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;4. I can now hit any of our APIs and it would return the data.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now in my M code, I'm able to get the Access_Token but not finding the proper option to send that to our cookie URL(Option 2 and 3).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this explains.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Oct 2020 07:08:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Using-Cookies-in-Power-Query-M/m-p/1432314#M26112</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-10-14T07:08:27Z</dc:date>
    </item>
    <item>
      <title>Re: Using Cookies in Power Query(M)</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Using-Cookies-in-Power-Query-M/m-p/1432506#M26113</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Did you change &lt;STRONG&gt;Header&lt;/STRONG&gt; to &lt;STRONG&gt;Headers&lt;/STRONG&gt;?&lt;/P&gt;&lt;P&gt;When you say you haven't had any success getting the cookie, how do you know?&amp;nbsp; Are you receiving an error?&lt;/P&gt;&lt;P&gt;Phil&lt;/P&gt;</description>
      <pubDate>Wed, 14 Oct 2020 08:06:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Using-Cookies-in-Power-Query-M/m-p/1432506#M26113</guid>
      <dc:creator>PhilipTreacy</dc:creator>
      <dc:date>2020-10-14T08:06:21Z</dc:date>
    </item>
    <item>
      <title>Re: Using Cookies in Power Query(M)</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Using-Cookies-in-Power-Query-M/m-p/1432748#M26114</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/264323"&gt;@PhilipTreacy&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did change it to Headers, it did not make any difference. The error returned:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;STRONG&gt;“DataFormat.Error: We found extra characters at the end of JSON input.&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Details:&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Value=&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Position=4″&lt;/STRONG&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;AND&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;204 No Content&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;which is returned with the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;try&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;operator if there is an error&lt;STRONG&gt;.&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now this error is returned because I'm hitting our APIs and collecting a JSON response, whereas this is actually returning a HTML response which is the sign in page. I had verified the process in POSTMAN as we can't see everything in Power BI Desktop.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Oct 2020 09:14:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Using-Cookies-in-Power-Query-M/m-p/1432748#M26114</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-10-14T09:14:11Z</dc:date>
    </item>
    <item>
      <title>Re: Using Cookies in Power Query(M)</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Using-Cookies-in-Power-Query-M/m-p/1432758#M26116</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Here's my complete code:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;section Software;&lt;/P&gt;&lt;P&gt;//&lt;BR /&gt;// OAuth configuration settings&lt;BR /&gt;//&lt;BR /&gt;username=Json.Document(Extension.Contents("source.json")) [source][username];&lt;BR /&gt;password=Json.Document(Extension.Contents("source.json")) [source][password];&lt;BR /&gt;client_id = Json.Document(Extension.Contents("source.json")) [source][client_id];&lt;BR /&gt;redirect_uri = Json.Document(Extension.Contents("source.json")) [source][redirect_uri];&lt;BR /&gt;token_uri = Json.Document(Extension.Contents("source.json")) [source][token_uri];&lt;BR /&gt;authorize_uri = Json.Document(Extension.Contents("source.json")) [source][authorize_uri];&lt;BR /&gt;logout_uri = Json.Document(Extension.Contents("source.json")) [source][logout_uri];&lt;/P&gt;&lt;P&gt;windowWidth = 720;&lt;BR /&gt;windowHeight = 1024;&lt;/P&gt;&lt;P&gt;scope_prefix = "&lt;A href="https://graph.microsoft.com/" target="_blank" rel="nofollow noopener noreferrer"&gt;https://graph.microsoft.com/&lt;/A&gt;";&lt;BR /&gt;scopes = {&lt;BR /&gt;"User.Read",&lt;BR /&gt;"openid"&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;// Helper Functions&lt;BR /&gt;Value.IfNull = (a, b) =&amp;gt; if a &amp;lt;&amp;gt; null then a else b;&lt;/P&gt;&lt;P&gt;GetScopeString = (scopes as list, optional scopePrefix as text) as text =&amp;gt;&lt;BR /&gt;let&lt;BR /&gt;prefix = Value.IfNull(scopePrefix, ""),&lt;BR /&gt;addPrefix = List.Transform(scopes, each prefix &amp;amp; _),&lt;BR /&gt;asText = Text.Combine(addPrefix, " ")&lt;BR /&gt;in&lt;BR /&gt;asText;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;// Data Source definition. OAuth Process:&lt;BR /&gt;Software = [&lt;BR /&gt;TestConnection = (dataSourcePath) =&amp;gt; { "Software.Contents" },&lt;BR /&gt;Authentication = [&lt;BR /&gt;OAuth = [&lt;BR /&gt;StartLogin=StartLogin,&lt;BR /&gt;FinishLogin=FinishLogin,&lt;BR /&gt;Refresh=Refresh,&lt;BR /&gt;Logout=Logout&lt;BR /&gt;]&lt;BR /&gt;],&lt;BR /&gt;Label = "Software Connector"&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;StartLogin = (resourceUrl, state, display) =&amp;gt;&lt;BR /&gt;let&lt;BR /&gt;authorizeUrl = authorize_uri &amp;amp; "?" &amp;amp; Uri.BuildQueryString([&lt;BR /&gt;client_id = client_id,&lt;BR /&gt;redirect_uri = redirect_uri,&lt;BR /&gt;state = state,&lt;BR /&gt;scope = "offline_access " &amp;amp; GetScopeString(scopes, scope_prefix),&lt;BR /&gt;response_type = "code",&lt;BR /&gt;response_mode = "query",&lt;BR /&gt;login = "login"&lt;BR /&gt;])&lt;BR /&gt;in&lt;BR /&gt;[&lt;BR /&gt;LoginUri = authorizeUrl,&lt;BR /&gt;CallbackUri = redirect_uri,&lt;BR /&gt;WindowHeight = 720,&lt;BR /&gt;WindowWidth = 1024,&lt;BR /&gt;Context = null&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;FinishLogin = (context, callbackUri, state) =&amp;gt;&lt;BR /&gt;let&lt;BR /&gt;// parse the full callbackUri, and extract the Query string&lt;BR /&gt;parts = Uri.Parts(callbackUri)[Query],&lt;BR /&gt;// if the query string contains an "error" field, raise an error&lt;BR /&gt;// otherwise call TokenMethod to exchange our code for an access_token&lt;BR /&gt;result = if (Record.HasFields(parts, {"error", "error_description"})) then&lt;BR /&gt;error Error.Record(parts[error], parts[error_description], parts)&lt;BR /&gt;else&lt;BR /&gt;TokenMethod("authorization_code", "code", parts[code])&lt;BR /&gt;in&lt;BR /&gt;result;&lt;/P&gt;&lt;P&gt;// Called when the access_token has expired, and a refresh_token is available.&lt;BR /&gt;Refresh = (resourceUrl, refresh_token) =&amp;gt; TokenMethod("refresh_token", "refresh_token", refresh_token);&lt;/P&gt;&lt;P&gt;Logout = (token) =&amp;gt; logout_uri;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;TokenMethod = (grantType, tokenField, code) =&amp;gt;&lt;BR /&gt;let&lt;BR /&gt;queryString = [&lt;BR /&gt;client_id=client_id,&lt;BR /&gt;scope= Json.Document(Extension.Contents("Source.json")) [source] [scope],&lt;BR /&gt;grant_type="password",&lt;BR /&gt;response_type="token",&lt;BR /&gt;username=username,&lt;BR /&gt;password=password&lt;BR /&gt;],&lt;BR /&gt;queryWithCode = Record.AddField(queryString, tokenField, code),&lt;/P&gt;&lt;P&gt;tokenResponse = Web.Contents(token_uri, [&lt;BR /&gt;Content = Text.ToBinary(Uri.BuildQueryString(queryWithCode)),&lt;BR /&gt;Headers = [&lt;BR /&gt;#"Content-type" = "application/x-www-form-urlencoded",&lt;BR /&gt;#"Accept" = "application/json"&lt;BR /&gt;],&lt;BR /&gt;ManualStatusHandling = {400}&lt;BR /&gt;]),&lt;BR /&gt;body = Json.Document(tokenResponse),&lt;BR /&gt;result = if (Record.HasFields(body, {"error", "error_description"})) then&lt;BR /&gt;error Error.Record(body[error], body[error_description], body)&lt;BR /&gt;else&lt;BR /&gt;body&lt;BR /&gt;in&lt;BR /&gt;result;&lt;/P&gt;&lt;P&gt;//OAuth Process completes here//&lt;/P&gt;&lt;P&gt;//Cookies Process Below:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Cookies_URL = "https://domain/CloudAssessmentService/api/cookie";&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Cookies = () =&amp;gt;&lt;BR /&gt;let&lt;BR /&gt;// Source = //Web.Contents("https://domain/CloudAssessmentService/api/cookie", Content=[GET])&lt;/P&gt;&lt;P&gt;content = "{&lt;BR /&gt;""method"": ""get"",&lt;BR /&gt;}",&lt;/P&gt;&lt;P&gt;Source = TokenMethod,&lt;BR /&gt;GetCookies = Web.Contents("https://domain/CloudAssessmentService/api/cookie", [Headers=[Authorization="Bearer " &amp;amp; Record.Field(Source, "body")], Content=Text.ToBinary(content)])&lt;BR /&gt;in&lt;BR /&gt;GetCookies;&lt;BR /&gt;&lt;BR /&gt;// if&lt;BR /&gt;// TokenMethod{[tokenResponse]}[body] then&lt;BR /&gt;// Web.Contents("https://domain/CloudAssessmentService/api/cookie", [Header = DefaultRequestHeaders])&lt;BR /&gt;// else&lt;BR /&gt;// null;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;// let&lt;BR /&gt;// cookieResponse = Json.Document(TokenMethod),&lt;BR /&gt;// result = if(Record.HasFields(cookieResponse)) then&lt;BR /&gt;// Web.Contents("https://domain/CloudAssessmentService/api/cookie")&lt;BR /&gt;// else&lt;BR /&gt;// error Error.Record(TokenMethod)&lt;BR /&gt;// in&lt;BR /&gt;// result;&lt;/P&gt;&lt;P&gt;// let&lt;/P&gt;&lt;P&gt;// content = "{&lt;BR /&gt;// ""method"": ""get"",&lt;BR /&gt;&lt;BR /&gt;// }",&lt;/P&gt;&lt;P&gt;// Source = Json.Document(Web.Contents("https://domain/CloudAssessmentService/api/cookie", [Headers=[Authorization="Bearer AQAAAAANlKwBAAQQn4Wfgbxxxxxxxxxx"], Content=Text.ToBinary(content)]))&lt;BR /&gt;//in&lt;BR /&gt;// Source;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;///TryToken = () =&amp;gt;&lt;BR /&gt;// let&lt;BR /&gt;// GetSoftwareAccessToken = TokenMethod,&lt;BR /&gt;// HTTPHeader = [Header = [#"Authorization"= "Bearer " &amp;amp; GetSoftwareAccessToken, #"Content-Type" = "application/json"]],&lt;BR /&gt;// CookieRequest = Web.Contents("https://domain/CloudAssessmentService/api/cookie", HTTPHeader)&lt;BR /&gt;// in&lt;BR /&gt;// CookieRequest;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;// Exported function(s) Data Source.&lt;BR /&gt;[DataSource.Kind="Software", Publish="Software.Publish"]&lt;/P&gt;&lt;P&gt;shared Software.Contents = Value.ReplaceType(SoftwareNavTable, type function(url as Uri.Type) as any);&lt;/P&gt;&lt;P&gt;SoftwareNavTable = (url as text) as table =&amp;gt;&lt;BR /&gt;let&lt;BR /&gt;//cookies = TryToken,&lt;BR /&gt;entitiesAsTable = RootEntities,&lt;BR /&gt;// Add Data as a calculated column&lt;BR /&gt;withData = Table.AddColumn(entitiesAsTable, "Data", each Software.Feed(Uri.Combine(url, [Query])), Uri.Type),&lt;BR /&gt;// Add ItemKind and ItemName as fixed text values&lt;BR /&gt;withItemKind = Table.AddColumn(withData, "ItemKind", each "Table", type text),&lt;BR /&gt;withItemName = Table.AddColumn(withItemKind, "ItemName", each "Table", type text),&lt;BR /&gt;// Indicate that the node should not be expandable&lt;BR /&gt;withIsLeaf = Table.AddColumn(withItemName, "IsLeaf", each true, type logical),&lt;BR /&gt;// Generate the nav table&lt;BR /&gt;outputTable = Table.RemoveColumns(withIsLeaf, "Query"),&lt;BR /&gt;navTable = Table.ToNavigationTable(outputTable, {"Name"}, "Name", "Data", "ItemKind", "ItemName", "IsLeaf")&lt;BR /&gt;in&lt;BR /&gt;navTable;&lt;/P&gt;&lt;P&gt;//API Calls&lt;BR /&gt;RootEntities = #table({"Name", "Query"}, {&lt;BR /&gt;{"Software Systems", "/api/systems"},&lt;BR /&gt;{"Health Data", "/api/visualizers/desktop/"},&lt;BR /&gt;{"User Data", "/api/visualizers/persona/"},&lt;BR /&gt;{"Power", "/api/visualizers/Desktop/"},&lt;BR /&gt;{"Software Packages", "/api/visualizers/"},&lt;BR /&gt;{"Storage", "/api/visualizers/Desktop/"},&lt;BR /&gt;{"System Mobility", "/api/visualizers/Desktop/"},&lt;BR /&gt;{"Real Time Health", "api/virtual/objects"}});&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Software.Feed = (url as text) =&amp;gt;&lt;BR /&gt;let&lt;BR /&gt;//credential = Extension.CurrentCredential(),&lt;/P&gt;&lt;P&gt;//CredentialConnectionString = [ credential = source[username], PWD = source[password] ],&lt;/P&gt;&lt;P&gt;//then&lt;BR /&gt;source = Web.Contents(url, [Headers = DefaultRequestHeaders]),&lt;BR /&gt;json = Json.Document(source),&lt;BR /&gt;ColumnQuery = json,&lt;BR /&gt;ColumnData = ColumnQuery[data],&lt;BR /&gt;ColumnData1 = ColumnData{0},&lt;BR /&gt;Columns = ColumnData1[Columns],&lt;BR /&gt;#"ColumnTable" = Table.FromList(Columns, Splitter.SplitByNothing(), null, null, ExtraValues.Error),&lt;BR /&gt;#"Expanded ColumnTable" = Table.ExpandRecordColumn(#"ColumnTable", "Column1", {"Name"}, {"Column1.Name"}),&lt;BR /&gt;#"Transposed ColumnTable" = Table.Transpose(#"Expanded ColumnTable"),&lt;BR /&gt;#"ColumnTable Headers" = Table.PromoteHeaders(#"Transposed ColumnTable", [PromoteAllScalars=true]),&lt;BR /&gt;RowQuery = json,&lt;BR /&gt;RowData = RowQuery[data],&lt;BR /&gt;RowData1 = RowData{0},&lt;BR /&gt;Rows = RowData1[Rows],&lt;BR /&gt;#"RowTable" = Table.FromList(Rows, Splitter.SplitByNothing(), null, null, ExtraValues.Error),&lt;BR /&gt;RowCheck = try Table.ExpandRecordColumn(#"RowTable", "Column1", {"Values"}, {"Column1.Values"}),&lt;BR /&gt;#"Expanded RowTable" = Table.ExpandRecordColumn(#"RowTable", "Column1", {"Values"}, {"Column1.Values"}),&lt;BR /&gt;#"Extracted Values" = Table.TransformColumns(#"Expanded RowTable", {"Column1.Values", each Combiner.CombineTextByDelimiter("$")(List.Transform(_, Text.From)), type text}),&lt;BR /&gt;#"Split RowTable" = Table.SplitColumn(#"Extracted Values", "Column1.Values", Splitter.SplitTextByDelimiter("$", QuoteStyle.Csv)),&lt;BR /&gt;outcome = List.Count(Table.ColumnNames(#"ColumnTable Headers")) &amp;gt; List.Count(Table.ColumnNames( #"Split RowTable")),&lt;BR /&gt;#"Split RowTableMod" = if outcome then Table.AddColumn(#"Split RowTable", "Custom", each null) else #"Split RowTable",&lt;BR /&gt;#"OutputTable0" = Table.RenameColumns(#"Split RowTableMod", List.Zip({Table.ColumnNames(#"Split RowTableMod"),Table.ColumnNames(#"ColumnTable Headers")})),&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;//else&lt;BR /&gt;Data = json[data],&lt;BR /&gt;#"DataTable" = Table.FromList(Data, Splitter.SplitByNothing(), null, null, ExtraValues.Error),&lt;BR /&gt;Column = #"DataTable"{0}[Column1],&lt;BR /&gt;#"ColumnTable1" = Record.ToTable(Column),&lt;BR /&gt;#"ColumnTableRemovedValues" = Table.RemoveColumns( #"ColumnTable1",{"Value"}),&lt;BR /&gt;#"OutputTable1" = Table.ExpandRecordColumn(#"DataTable", "Column1", Table.ToList(#"ColumnTableRemovedValues")),&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;visualizerQuery = Text.Contains(url, "visualizers"),&lt;BR /&gt;RealTimeHealthQuery = Text.Contains(url, "virtual/objects"),&lt;BR /&gt;SoftwareSystemsQuery = Text.Contains(url, "api/systems"),&lt;BR /&gt;&lt;BR /&gt;result = if RowCheck[HasError] and visualizerQuery&lt;BR /&gt;then "Status: 204 No Content"&lt;BR /&gt;else if visualizerQuery&lt;BR /&gt;then #"OutputTable0"&lt;BR /&gt;else if RealTimeHealthQuery&lt;BR /&gt;then Table.ExpandRecordColumn(#"OutputTable1", "health", {"time", "usage", "summary", "cpu", "statuses"}, {"health.time", "health.usage", "health.summary", "health.cpu", "health.statuses"})&lt;BR /&gt;else if SoftwareSystemsQuery&lt;BR /&gt;then Table.RenameColumns(#"OutputTable1",{{"sysGuid", "WGUID"}})&lt;BR /&gt;else #"OutputTable1"&lt;BR /&gt;in&lt;BR /&gt;result;&lt;/P&gt;&lt;P&gt;Table.ToNavigationTable = (&lt;BR /&gt;table as table,&lt;BR /&gt;keyColumns as list,&lt;BR /&gt;nameColumn as text,&lt;BR /&gt;dataColumn as text,&lt;BR /&gt;itemKindColumn as text,&lt;BR /&gt;itemNameColumn as text,&lt;BR /&gt;isLeafColumn as text&lt;BR /&gt;) as table =&amp;gt;&lt;BR /&gt;let&lt;BR /&gt;tableType = Value.Type(table),&lt;BR /&gt;newTableType = Type.AddTableKey(tableType, keyColumns, true) meta&lt;BR /&gt;[&lt;BR /&gt;NavigationTable.NameColumn = nameColumn,&lt;BR /&gt;NavigationTable.DataColumn = dataColumn,&lt;BR /&gt;NavigationTable.ItemKindColumn = itemKindColumn,&lt;BR /&gt;Preview.DelayColumn = itemNameColumn,&lt;BR /&gt;NavigationTable.IsLeafColumn = isLeafColumn&lt;BR /&gt;],&lt;BR /&gt;navigationTable = Value.ReplaceType(table, newTableType)&lt;BR /&gt;in&lt;BR /&gt;navigationTable;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;DefaultRequestHeaders = [&lt;/P&gt;&lt;P&gt;#"Accept" = "application/json"&lt;BR /&gt;&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;SoftwareImpl = (url as text) =&amp;gt;&lt;/P&gt;&lt;P&gt;let&lt;BR /&gt;source = Web.Contents(url, [Headers = DefaultRequestHeaders]),&lt;BR /&gt;json = Json.Document(source)&lt;BR /&gt;in&lt;BR /&gt;json;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;// UserInterface Export definition&lt;BR /&gt;Software.Publish = [&lt;BR /&gt;Beta = true,&lt;BR /&gt;ButtonText = { "Software.Contents", "Connect to Software" },&lt;BR /&gt;SourceImage = Software.Icons,&lt;BR /&gt;SourceTypeImage = Software.Icons&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;Software.Icons = [&lt;BR /&gt;Icon16 = { Extension.Contents("Software16.png"), Extension.Contents("Software20.png"), Extension.Contents("Software24.png"), Extension.Contents("Software32.png") },&lt;BR /&gt;Icon32 = { Extension.Contents("Software32.png"), Extension.Contents("Software40.png"), Extension.Contents("Software48.png"), Extension.Contents("Software64.png") }&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;// UI Export definition completes here//&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Oct 2020 09:18:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Using-Cookies-in-Power-Query-M/m-p/1432758#M26116</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-10-14T09:18:22Z</dc:date>
    </item>
    <item>
      <title>Re: Using Cookies in Power Query(M)</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Using-Cookies-in-Power-Query-M/m-p/1433301#M26119</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/264323"&gt;@PhilipTreacy&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my Code which has just the OAuth logic and the Cookies method:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;//&lt;BR /&gt;// OAuth configuration settings&lt;BR /&gt;//&lt;BR /&gt;username=Json.Document(Extension.Contents("source.json")) [source][username];&lt;BR /&gt;password=Json.Document(Extension.Contents("source.json")) [source][password];&lt;BR /&gt;client_id = Json.Document(Extension.Contents("source.json")) [source][client_id];&lt;BR /&gt;redirect_uri = Json.Document(Extension.Contents("source.json")) [source][redirect_uri];&lt;BR /&gt;token_uri = Json.Document(Extension.Contents("source.json")) [source][token_uri];&lt;BR /&gt;authorize_uri = Json.Document(Extension.Contents("source.json")) [source][authorize_uri];&lt;BR /&gt;logout_uri = Json.Document(Extension.Contents("source.json")) [source][logout_uri];&lt;/P&gt;&lt;P&gt;windowWidth = 1000;&lt;BR /&gt;windowHeight = 1024;&lt;/P&gt;&lt;P&gt;scope_prefix = "&lt;A href="https://graph.microsoft.com/" target="_blank"&gt;https://graph.microsoft.com/&lt;/A&gt;";&lt;BR /&gt;scopes = {&lt;BR /&gt;"User.Read",&lt;BR /&gt;"openid"&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;// Helper Functions&lt;BR /&gt;Value.IfNull = (a, b) =&amp;gt; if a &amp;lt;&amp;gt; null then a else b;&lt;/P&gt;&lt;P&gt;GetScopeString = (scopes as list, optional scopePrefix as text) as text =&amp;gt;&lt;BR /&gt;let&lt;BR /&gt;prefix = Value.IfNull(scopePrefix, ""),&lt;BR /&gt;addPrefix = List.Transform(scopes, each prefix &amp;amp; _),&lt;BR /&gt;asText = Text.Combine(addPrefix, " ")&lt;BR /&gt;in&lt;BR /&gt;asText;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;// Data Source definition. OAuth Process:&lt;BR /&gt;Software = [&lt;BR /&gt;TestConnection = (dataSourcePath) =&amp;gt; { "Software.Contents" },&lt;BR /&gt;Authentication = [&lt;BR /&gt;OAuth = [&lt;BR /&gt;StartLogin=StartLogin,&lt;BR /&gt;FinishLogin=FinishLogin,&lt;BR /&gt;Refresh=Refresh,&lt;BR /&gt;Logout=Logout&lt;BR /&gt;]&lt;BR /&gt;],&lt;BR /&gt;Label = "Software Connector"&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;StartLogin = (resourceUrl, state, display) =&amp;gt;&lt;BR /&gt;let&lt;BR /&gt;authorizeUrl = authorize_uri &amp;amp; "?" &amp;amp; Uri.BuildQueryString([&lt;BR /&gt;client_id = client_id,&lt;BR /&gt;redirect_uri = redirect_uri,&lt;BR /&gt;state = state,&lt;BR /&gt;scope = "offline_access " &amp;amp; GetScopeString(scopes, scope_prefix),&lt;BR /&gt;response_type = "code",&lt;BR /&gt;response_mode = "query",&lt;BR /&gt;login = "login"&lt;BR /&gt;])&lt;BR /&gt;in&lt;BR /&gt;[&lt;BR /&gt;LoginUri = authorizeUrl,&lt;BR /&gt;CallbackUri = redirect_uri,&lt;BR /&gt;WindowHeight = 720,&lt;BR /&gt;WindowWidth = 1024,&lt;BR /&gt;Context = null&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;FinishLogin = (context, callbackUri, state) =&amp;gt;&lt;BR /&gt;let&lt;BR /&gt;// parse the full callbackUri, and extract the Query string&lt;BR /&gt;parts = Uri.Parts(callbackUri)[Query],&lt;BR /&gt;// if the query string contains an "error" field, raise an error&lt;BR /&gt;// otherwise call TokenMethod to exchange our code for an access_token&lt;BR /&gt;result = if (Record.HasFields(parts, {"error", "error_description"})) then&lt;BR /&gt;error Error.Record(parts[error], parts[error_description], parts)&lt;BR /&gt;else&lt;BR /&gt;TokenMethod("authorization_code", "code", parts[code])&lt;BR /&gt;in&lt;BR /&gt;result;&lt;/P&gt;&lt;P&gt;// Called when the access_token has expired, and a refresh_token is available.&lt;BR /&gt;Refresh = (resourceUrl, refresh_token) =&amp;gt; TokenMethod("refresh_token", "refresh_token", refresh_token);&lt;/P&gt;&lt;P&gt;Logout = (token) =&amp;gt; logout_uri;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;TokenMethod = (grantType, tokenField, code) =&amp;gt;&lt;BR /&gt;let&lt;BR /&gt;queryString = [&lt;BR /&gt;client_id=client_id,&lt;BR /&gt;scope= Json.Document(Extension.Contents("Source.json")) [source] [scope],&lt;BR /&gt;grant_type="password",&lt;BR /&gt;response_type="token",&lt;BR /&gt;username=username,&lt;BR /&gt;password=password&lt;BR /&gt;],&lt;BR /&gt;queryWithCode = Record.AddField(queryString, tokenField, code),&lt;/P&gt;&lt;P&gt;tokenResponse = Web.Contents(token_uri, [&lt;BR /&gt;Content = Text.ToBinary(Uri.BuildQueryString(queryWithCode)),&lt;BR /&gt;Headers = [&lt;BR /&gt;#"Content-type" = "application/x-www-form-urlencoded",&lt;BR /&gt;#"Accept" = "application/json"&lt;BR /&gt;],&lt;BR /&gt;ManualStatusHandling = {400}&lt;BR /&gt;]),&lt;BR /&gt;body = Json.Document(tokenResponse),&lt;BR /&gt;result = if (Record.HasFields(body, {"error", "error_description"})) then&lt;BR /&gt;error Error.Record(body[error], body[error_description], body)&lt;BR /&gt;else&lt;BR /&gt;body&lt;BR /&gt;&lt;BR /&gt;in&lt;BR /&gt;result;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;[DataSource.Kind="SoftwareConnector", Publish="Software.Publish"]&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;shared Software.Contents = (url as text) =&amp;gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;let&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;source = Json.Document(Web.Contents(url))&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;in&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;source;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;//Get the tenant Cookie&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;GetCookies = (url as text) =&amp;gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;let &lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;CookieResponse = Web.Contents("https://domain/CloudAssessmentService/api/cookie", [Headers = [#"Authorization"= "Bearer " &amp;amp; "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIm......", #"Content-Type" = "application/json"]])//////////////HARDCODED TOKEN//////////&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;in&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;CookieResponse;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;TryToken = () =&amp;gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;let &lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;GetSoftwareAccessToken = TokenMethod,&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;HTTPHeader = [Headers = [#"Authorization"= "Bearer " &amp;amp; GetSoftwareAccessToken, #"Content-Type" = "application/json"]],&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;CookieRequest = WebMethod.Get(Web.Contents("https://domain/CloudAssessmentService/api/cookie", HTTPHeader))/////////////DYNAMIC TOKEN BASED ON THE TOKEN METHOD//////////////////&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;in &lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;CookieRequest;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//&lt;BR /&gt;// Exported function(s)&lt;BR /&gt;//&lt;/P&gt;&lt;P&gt;Software.Publish = [&lt;BR /&gt;Beta = true,&lt;BR /&gt;ButtonText = { "Software.Contents", "Connect to Software" },&lt;BR /&gt;SourceImage = Software.Icons,&lt;BR /&gt;SourceTypeImage = Software.Icons&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;Software.Icons = [&lt;BR /&gt;Icon16 = { Extension.Contents("Software16.png"), Extension.Contents("Software20.png"), Extension.Contents("Software24.png"), Extension.Contents("Software32.png") },&lt;BR /&gt;Icon32 = { Extension.Contents("Software32.png"), Extension.Contents("Software40.png"), Extension.Contents("Software48.png"), Extension.Contents("Software64.png") }&lt;BR /&gt;];&lt;/P&gt;&lt;BR /&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I've highlighted Cookies functions and also the Data Source description as I'm now confused if I should call these cookies functions explicitly somewhere or in the Data Source description.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Oct 2020 12:54:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Using-Cookies-in-Power-Query-M/m-p/1433301#M26119</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-10-14T12:54:19Z</dc:date>
    </item>
    <item>
      <title>Re: Using Cookies in Power Query(M)</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Using-Cookies-in-Power-Query-M/m-p/1515916#M26594</link>
      <description>&lt;P&gt;Does anyone know if power query works with Cookies. I have tried many different stuff after my last response here and haven't had any success. On one of the post in the community it was mentioned that powerquery doesn't work with cookies(&lt;A href="https://community.powerbi.com/t5/Developer/How-to-get-set-Cookies-inside-a-visual/m-p/347843" target="_blank"&gt;https://community.powerbi.com/t5/Developer/How-to-get-set-Cookies-inside-a-visual/m-p/347843&lt;/A&gt;). Is this still the case?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Appreciate any response.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Nov 2020 10:08:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Using-Cookies-in-Power-Query-M/m-p/1515916#M26594</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-11-25T10:08:18Z</dc:date>
    </item>
    <item>
      <title>Re: Using Cookies in Power Query(M)</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Using-Cookies-in-Power-Query-M/m-p/1562147#M26824</link>
      <description>&lt;P&gt;Its been quite some time and I'm still trying to get information on this. I know we would go out of vacation soon or some would already be on vacation. I would appreciate any inputs before we all head out to our vacation.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Wishing you all happy holidays.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Dec 2020 08:36:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Using-Cookies-in-Power-Query-M/m-p/1562147#M26824</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-12-21T08:36:43Z</dc:date>
    </item>
    <item>
      <title>Re: Using Cookies in Power Query(M)</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Using-Cookies-in-Power-Query-M/m-p/1586047#M27092</link>
      <description>&lt;P&gt;Hello Team&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm still chasing for the information on cookies. I would appreciate any response.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jan 2021 09:28:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Using-Cookies-in-Power-Query-M/m-p/1586047#M27092</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-01-07T09:28:43Z</dc:date>
    </item>
    <item>
      <title>Re: Using Cookies in Power Query(M)</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Using-Cookies-in-Power-Query-M/m-p/3033853#M40829</link>
      <description>&lt;P&gt;Is this thread still active?&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2023 12:17:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Using-Cookies-in-Power-Query-M/m-p/3033853#M40829</guid>
      <dc:creator>Ganesh_00</dc:creator>
      <dc:date>2023-01-20T12:17:23Z</dc:date>
    </item>
  </channel>
</rss>

