<?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 programmatic data refresh using api in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/programmatic-data-refresh-using-api/m-p/219617#M6918</link>
    <description>&lt;P&gt;I have found that with the new PBI API there is an option to &lt;A href="https://msdn.microsoft.com/en-us/library/mt784652.aspx" target="_self"&gt;trigger a dataset refresh programatically&lt;/A&gt;. &amp;nbsp;I was looking at implementing this into a powershell script that could be called at the end of our nightly job loads. &amp;nbsp;I found a open source powershell script that uses the API:&amp;nbsp;&lt;A href="https://github.com/Azure-Samples/powerbi-powershell" target="_self"&gt;https://github.com/Azure-Samples/powerbi-powershell&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I filled in the script with the info needed and it works. &amp;nbsp;However when i run the script I am forced to manually sign in via AAD to generate the required token used in the API call. &amp;nbsp;The plan is to run this powershell script in a job automatically so I would need the login to be handled automatically.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I make the login automatic so that I do not need to manually log in each time i run this script?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Without knowing much about powershell scripting I'm assuming that the following code needs to be changed:&lt;/P&gt;&lt;PRE&gt;       $authResult = $authContext.AcquireToken($resourceAppIdURI, $clientId, $redirectUri, "Auto")&lt;/PRE&gt;&lt;P&gt;Rather than passing in "Auto", I would assume that there is some way to pass in user credentials instead.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Wed, 26 Jul 2017 16:00:32 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2017-07-26T16:00:32Z</dc:date>
    <item>
      <title>programmatic data refresh using api</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/programmatic-data-refresh-using-api/m-p/219617#M6918</link>
      <description>&lt;P&gt;I have found that with the new PBI API there is an option to &lt;A href="https://msdn.microsoft.com/en-us/library/mt784652.aspx" target="_self"&gt;trigger a dataset refresh programatically&lt;/A&gt;. &amp;nbsp;I was looking at implementing this into a powershell script that could be called at the end of our nightly job loads. &amp;nbsp;I found a open source powershell script that uses the API:&amp;nbsp;&lt;A href="https://github.com/Azure-Samples/powerbi-powershell" target="_self"&gt;https://github.com/Azure-Samples/powerbi-powershell&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I filled in the script with the info needed and it works. &amp;nbsp;However when i run the script I am forced to manually sign in via AAD to generate the required token used in the API call. &amp;nbsp;The plan is to run this powershell script in a job automatically so I would need the login to be handled automatically.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I make the login automatic so that I do not need to manually log in each time i run this script?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Without knowing much about powershell scripting I'm assuming that the following code needs to be changed:&lt;/P&gt;&lt;PRE&gt;       $authResult = $authContext.AcquireToken($resourceAppIdURI, $clientId, $redirectUri, "Auto")&lt;/PRE&gt;&lt;P&gt;Rather than passing in "Auto", I would assume that there is some way to pass in user credentials instead.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jul 2017 16:00:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/programmatic-data-refresh-using-api/m-p/219617#M6918</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-07-26T16:00:32Z</dc:date>
    </item>
    <item>
      <title>Re: programmatic data refresh using api</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/programmatic-data-refresh-using-api/m-p/220129#M6947</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I have found that with the new PBI API there is an option to &lt;A href="https://msdn.microsoft.com/en-us/library/mt784652.aspx" target="_self"&gt;trigger a dataset refresh programatically&lt;/A&gt;. &amp;nbsp;I was looking at implementing this into a powershell script that could be called at the end of our nightly job loads. &amp;nbsp;I found a open source powershell script that uses the API:&amp;nbsp;&lt;A href="https://github.com/Azure-Samples/powerbi-powershell" target="_self"&gt;https://github.com/Azure-Samples/powerbi-powershell&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I filled in the script with the info needed and it works. &amp;nbsp;However when i run the script I am forced to manually sign in via AAD to generate the required token used in the API call. &amp;nbsp;The plan is to run this powershell script in a job automatically so I would need the login to be handled automatically.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can I make the login automatic so that I do not need to manually log in each time i run this script?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Without knowing much about powershell scripting I'm assuming that the following code needs to be changed:&lt;/P&gt;
&lt;PRE&gt;       $authResult = $authContext.AcquireToken($resourceAppIdURI, $clientId, $redirectUri, "Auto")&lt;/PRE&gt;
&lt;P&gt;Rather than passing in "Auto", I would assume that there is some way to pass in user credentials instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help would be appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;@Anonymous&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Based on my test, I can get the access token in a silent way without any popup login window. Just ensure that the account used in this demo is &lt;A href="https://powerbi.microsoft.com/en-us/documentation/powerbi-developer-register-app/#apply-permissions-to-your-application-within-azure-ad" target="_self"&gt;granted permission&lt;/A&gt; in that AAD application.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt; static string getAccessTokenSilently()
        {
            string resourceUri = "https://analysis.windows.net/powerbi/api";
            HttpWebRequest request = System.Net.HttpWebRequest.CreateHttp("https://login.windows.net/common/oauth2/token");
            //POST web request to create a datasource.
            request.KeepAlive = true;
            request.Method = "POST";
            request.ContentLength = 0;
            request.ContentType = "application/x-www-form-urlencoded"; 

            NameValueCollection parsedQueryString = HttpUtility.ParseQueryString(String.Empty);
            parsedQueryString.Add("client_id", clientID);
            parsedQueryString.Add("grant_type", "password");
            parsedQueryString.Add("resource", resourceUri);
            parsedQueryString.Add("username", username);
            parsedQueryString.Add("password", password);
            string postdata = parsedQueryString.ToString();


            //POST web request
            byte[] dataByteArray = System.Text.Encoding.ASCII.GetBytes(postdata); ;
            request.ContentLength = dataByteArray.Length;

            //Write JSON byte[] into a Stream
            using (Stream writer = request.GetRequestStream())
            {
                writer.Write(dataByteArray, 0, dataByteArray.Length);
                var response = (HttpWebResponse)request.GetResponse();
                var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
                dynamic responseJson = JsonConvert.DeserializeObject&amp;lt;dynamic&amp;gt;(responseString);
                return responseJson["access_token"];
            }


        }&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Jul 2017 08:53:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/programmatic-data-refresh-using-api/m-p/220129#M6947</guid>
      <dc:creator>Eric_Zhang</dc:creator>
      <dc:date>2017-07-27T08:53:04Z</dc:date>
    </item>
    <item>
      <title>Re: programmatic data refresh using api</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/programmatic-data-refresh-using-api/m-p/223051#M7045</link>
      <description>&lt;P&gt;Thanks for the response &lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/6971"&gt;@Eric_Zhang&lt;/a&gt;, it let me know that what I was trying to achieve could be done. &amp;nbsp;I did some more digging and was able to modify the function in the PS script to use supplied credentials:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;function GetAuthToken
{
    $adal = "${env:ProgramFiles(x86)}\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Services\Microsoft.IdentityModel.Clients.ActiveDirectory.dll"
 
    $adalforms = "${env:ProgramFiles(x86)}\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Services\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll"
 
    [System.Reflection.Assembly]::LoadFrom($adal) | Out-Null
 
    [System.Reflection.Assembly]::LoadFrom($adalforms) | Out-Null
 
    $redirectUri = "https://login.live.com/oauth20_desktop.srf"
 
    $resourceAppIdURI = "https://analysis.windows.net/powerbi/api"
 
    $authority = "https://login.windows.net/common/oauth2/authorize";
       
    $userName = "MyUN@tenant.com"

    $password = "MyPW"

    $creds = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.UserCredential" -ArgumentList $userName,$password
 
    $authContext = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext" -ArgumentList $authority

    $authResult = $authContext.AcquireToken($resourceAppIdURI, $clientId, $creds)
   

    return $authResult

}&lt;/PRE&gt;&lt;P&gt;Obviously I won't be hardcoding these credentials in the script but for testing purposes it works!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EDIT: &amp;nbsp;it looks like my code block has been invaded with emoji's. &amp;nbsp;If anyone is wondering you would replace the emoji with a colon ":" and the letter "P".&lt;/P&gt;</description>
      <pubDate>Tue, 01 Aug 2017 12:42:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/programmatic-data-refresh-using-api/m-p/223051#M7045</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-08-01T12:42:01Z</dc:date>
    </item>
    <item>
      <title>Re: programmatic data refresh using api</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/programmatic-data-refresh-using-api/m-p/338551#M10013</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;SPAN class=""&gt;&lt;A title="" href="https://community.powerbi.com/t5/user/viewprofilepage/user-id/8241" target="_self"&gt;rossnruthie&lt;/A&gt;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;I think I am using the same basic code as you to do refresh.&amp;nbsp; I too am being prompted to login to PowerBI and a windows security login.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;Where in powershell code would I put the code you have below?&amp;nbsp; Or you post your entire script?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;Here is my working script:&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;###########################################################################################&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;# This sample script calls the Power BI API to progammtically trigger a refresh for the dataset&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;# It then calls the Power BI API to progammatically to get the refresh history for that dataset&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;# For full documentation on the REST APIs, see:&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;# &lt;A href="https://msdn.microsoft.com/en-us/library/mt203551.aspx" target="_blank"&gt;https://msdn.microsoft.com/en-us/library/mt203551.aspx&lt;/A&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;# Instructions:&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;# 1. Install PowerShell (&lt;A href="https://msdn.microsoft.com/en-us/powershell/scripting/setup/installing-windows-powershell" target="_blank"&gt;https://msdn.microsoft.com/en-us/powershell/scripting/setup/installing-windows-powershell&lt;/A&gt;) and the Azure PowerShell cmdlets (&lt;A href="https://aka.ms/webpi-azps" target="_blank"&gt;https://aka.ms/webpi-azps&lt;/A&gt;)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;# 2. Set up a dataset for refresh in the Power BI service - make sure that the dataset can be &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;# updated successfully&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;# 3. Fill in the parameters below&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;# 4. Run the PowerShell script&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;# Parameters - fill these in before running the script!&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;# =====================================================&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;# An easy way to get group and dataset ID is to go to dataset settings and click on the dataset&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;# that you'd like to refresh. Once you do, the URL in the address bar will show the group ID and &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;# dataset ID, in the format: &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;# app.powerbi.com/groups/{groupID}/settings/datasets/{datasetID}&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;$groupID = "me" # the ID of the group that hosts the dataset. Use "me" if this is your My Workspace&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;$datasetID = "d234581a-734c-473c-be6c-e72f54ff9058" # the ID of the dataset that hosts the dataset&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;# AAD Client ID&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;# To get this, go to the following page and follow the steps to provision an app&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;# &lt;A href="https://dev.powerbi.com/apps" target="_blank"&gt;https://dev.powerbi.com/apps&lt;/A&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;# To get the sample to work, ensure that you have the following fields:&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;# App Type: Native app&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;# Redirect URL: urn:ietf:wg:oauth:2.0:oob&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;# Level of access: all dataset APIs&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;$clientId = "fbeb6bda-74a4-4a51-9c92-38a22c172a49"&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;# End Parameters =======================================&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;# Calls the Active Directory Authentication Library (ADAL) to authenticate against AAD&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;function GetAuthToken&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;{&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;$adal = "C:\Program Files\On-premises data gateway\Microsoft.IdentityModel.Clients.ActiveDirectory.dll"&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;$adalforms = "C:\Program Files\On-premises data gateway\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll"&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;[System.Reflection.Assembly]::LoadFrom($adal) | Out-Null&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;[System.Reflection.Assembly]::LoadFrom($adalforms) | Out-Null&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;$redirectUri = "urn:ietf:wg:oauth:2.0:oob"&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;$resourceAppIdURI = "&lt;A href="https://analysis.windows.net/powerbi/api" target="_blank"&gt;https://analysis.windows.net/powerbi/api&lt;/A&gt;"&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;$authority = "&lt;A href="https://login.microsoftonline.com/common/oauth2/authorize" target="_blank"&gt;https://login.microsoftonline.com/common/oauth2/authorize&lt;/A&gt;";&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;$authContext = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext" -ArgumentList $authority&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;$authResult = $authContext.AcquireToken($resourceAppIdURI, $clientId, $redirectUri, "Auto")&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;return $authResult&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;}&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;# Get the auth token from AAD&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;$token = GetAuthToken&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;# Building Rest API header with authorization token&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;$authHeader = @{&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;'Content-Type'='application/json'&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;'Authorization'=$token.CreateAuthorizationHeader()&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;}&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;# properly format groups path&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;$groupsPath = ""&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;if ($groupID -eq "me") {&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;$groupsPath = "myorg"&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;} else {&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;$groupsPath = "myorg/groups/$groupID"&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;}&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;# Refresh the dataset&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;$uri = "&lt;A href="https://api.powerbi.com/v1.0/$groupsPath/datasets/$datasetID/refreshes" target="_blank"&gt;https://api.powerbi.com/v1.0/$groupsPath/datasets/$datasetID/refreshes&lt;/A&gt;"&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Invoke-RestMethod -Uri $uri –Headers $authHeader –Method POST –Verbose&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;# Check the refresh history&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;$uri = "&lt;A href="https://api.powerbi.com/v1.0/$groupsPath/datasets/$datasetID/refreshes" target="_blank"&gt;https://api.powerbi.com/v1.0/$groupsPath/datasets/$datasetID/refreshes&lt;/A&gt;"&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Invoke-RestMethod -Uri $uri –Headers $authHeader –Method GET –Verbose&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;###########################################################################################&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Here are my two user prompts:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Prompt1.png" style="width: 598px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/77668i525BDFA7B89B9C67/image-size/large?v=v2&amp;amp;px=999" role="button" title="Prompt1.png" alt="Prompt1.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Prompt2.png" style="width: 598px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/77669i4C3AD0CCF8658C53/image-size/large?v=v2&amp;amp;px=999" role="button" title="Prompt2.png" alt="Prompt2.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2018 15:37:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/programmatic-data-refresh-using-api/m-p/338551#M10013</guid>
      <dc:creator>mcguija</dc:creator>
      <dc:date>2018-01-15T15:37:07Z</dc:date>
    </item>
    <item>
      <title>Re: programmatic data refresh using api</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/programmatic-data-refresh-using-api/m-p/340195#M10058</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/18646"&gt;@mcguija&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It looks like you are just using the redirect for the AcquireToken call.&amp;nbsp; This is what will pop up your login screen.&amp;nbsp; What you need to do is modify your AcquireToken to pass in a predefined user credential.&amp;nbsp; This will make the authentication silent and prevent the login from popping up.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is an example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;$groupID = "12345" 
$datasetID = "54321" 
$clientId = "67890" 

#Username and PW of the account that will be executing the refresh
$userName = "username@yourdomain.com"
$password = "userPasswordValue"
# End Parameters =======================================
&lt;BR /&gt;function GetAuthToken&lt;BR /&gt;{&lt;BR /&gt; $adal = "${env:ProgramFiles(x86)}\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Services\Microsoft.IdentityModel.Clients.ActiveDirectory.dll"&lt;BR /&gt; &lt;BR /&gt; $adalforms = "${env:ProgramFiles(x86)}\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Services\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll"&lt;BR /&gt; &lt;BR /&gt; [System.Reflection.Assembly]::LoadFrom($adal) | Out-Null&lt;BR /&gt; &lt;BR /&gt; [System.Reflection.Assembly]::LoadFrom($adalforms) | Out-Null&lt;BR /&gt; &lt;BR /&gt; &lt;STRONG&gt;#Don't need this&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; #$redirectUri = "https://login.live.com/oauth20_desktop.srf"#"urn:ietf:wg:oauth:2.0:oob"&lt;/STRONG&gt;&lt;BR /&gt; &lt;BR /&gt; $resourceAppIdURI = "https://analysis.windows.net/powerbi/api"&lt;BR /&gt; &lt;BR /&gt; $authority = "https://login.windows.net/common/oauth2/authorize";&lt;BR /&gt;&lt;BR /&gt; $authContext = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext" -ArgumentList $authority&lt;BR /&gt;&lt;BR /&gt; &lt;STRONG&gt;$creds = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.UserCredential" -ArgumentList $userName,$password &lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt; $authResult = $authContext.AcquireToken($resourceAppIdURI, $clientId, $creds)&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt; return $authResult&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;# Get the auth token from AAD&lt;BR /&gt;$token = GetAuthToken&lt;BR /&gt; &lt;BR /&gt;$token&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here I am creating an active directory user credential and assigning the UN/PW&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;$creds = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.UserCredential" -ArgumentList $userName,$password&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here I am taking the credentials I created in the previous step and passing it into the AcquireToken call.&amp;nbsp; This is different from what you are doing.&lt;/P&gt;&lt;PRE&gt;#My AcquireToken Call passing in the user credential i created:&lt;BR /&gt;$authResult = $authContext.AcquireToken($resourceAppIdURI, $clientId, $creds)&lt;BR /&gt;&lt;BR /&gt;#Your AcquireToken Call using the redirect and forcing a sign in pop-up:&lt;BR /&gt;$authResult = $authContext.AcquireToken($resourceAppIdURI, $clientId, $redirectUri, "Auto")&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jan 2018 17:20:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/programmatic-data-refresh-using-api/m-p/340195#M10058</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-01-17T17:20:01Z</dc:date>
    </item>
    <item>
      <title>Re: programmatic data refresh using api</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/programmatic-data-refresh-using-api/m-p/373316#M11129</link>
      <description>&lt;P&gt;This really helped me to skip SSO authentication step.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Mar 2018 17:48:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/programmatic-data-refresh-using-api/m-p/373316#M11129</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-03-09T17:48:55Z</dc:date>
    </item>
    <item>
      <title>Re: programmatic data refresh using api</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/programmatic-data-refresh-using-api/m-p/396366#M11799</link>
      <description>&lt;P&gt;I have this error message. And I have download and replace with older version of dll files but I still get same error. Can anyone help? Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Method invocation failed because [Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext] does not contain a method named 'AcquireToken'.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Apr 2018 23:28:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/programmatic-data-refresh-using-api/m-p/396366#M11799</guid>
      <dc:creator>HTAN</dc:creator>
      <dc:date>2018-04-13T23:28:32Z</dc:date>
    </item>
    <item>
      <title>Re: programmatic data refresh using api</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/programmatic-data-refresh-using-api/m-p/401133#M11962</link>
      <description>&lt;P&gt;same&lt;/P&gt;</description>
      <pubDate>Fri, 20 Apr 2018 15:59:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/programmatic-data-refresh-using-api/m-p/401133#M11962</guid>
      <dc:creator>duncfair</dc:creator>
      <dc:date>2018-04-20T15:59:45Z</dc:date>
    </item>
    <item>
      <title>Re: programmatic data refresh using api</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/programmatic-data-refresh-using-api/m-p/633119#M18650</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Thank you for your advices, but I getting this error too:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;New-Object : Cannot find an overload for “PSCredential” and the argument count: “2”&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Feb 2019 14:10:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/programmatic-data-refresh-using-api/m-p/633119#M18650</guid>
      <dc:creator>evtrifonov</dc:creator>
      <dc:date>2019-02-27T14:10:53Z</dc:date>
    </item>
    <item>
      <title>Re: programmatic data refresh using api</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/programmatic-data-refresh-using-api/m-p/866534#M21650</link>
      <description>&lt;P&gt;Use the following scripts which work perfect,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="co1"&gt;# Parameters - fill these in before running the script!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="co1"&gt;# =====================================================&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="co1"&gt;# An easy way to get group and dataset ID is to go to dataset settings and click on the dataset&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="co1"&gt;# that you'd like to refresh. Once you do, the URL in the address bar will show the group ID and &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="co1"&gt;# dataset ID, in the format: &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="co1"&gt;# app.powerbi.com/groups/{groupID}/settings/datasets/{datasetID} &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;$groupID = &lt;/SPAN&gt;&lt;SPAN class="st0"&gt;"me"&lt;/SPAN&gt; &lt;SPAN class="co1"&gt;# the ID of the group that hosts the dataset. Use "me" if this is your My Workspace&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;$datasetID = &lt;/SPAN&gt;&lt;SPAN class="st0"&gt;"d9b4fd0c-7ac9-4e5d-be42-76686ce6b2db"&lt;/SPAN&gt; &lt;SPAN class="co1"&gt;# the ID of the dataset that hosts the dataset&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="co1"&gt;# AAD Client ID&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="co1"&gt;# To get this, go to the following page and follow the steps to provision an app&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="co1"&gt;# &lt;A href="https://dev.powerbi.com/apps" target="_blank"&gt;https://dev.powerbi.com/apps&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="co1"&gt;# To get the sample to work, ensure that you have the following fields:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="co1"&gt;# App Type: Native app&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="co1"&gt;# Redirect URL: urn:ietf:wg:oauth:2.0:oob&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="co1"&gt;# Level of access: all dataset APIs&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;$clientId = &lt;/SPAN&gt;&lt;SPAN class="st0"&gt;"Client ID"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="co1"&gt;# End Parameters =======================================&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="co1"&gt;# Calls the Active Directory Authentication Library (ADAL) to authenticate against AAD&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="co1"&gt;# update the dll files path if the versions are different like 5.1.2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;function GetAuthToken&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="br0"&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;$adal = &lt;/SPAN&gt;&lt;SPAN class="st0"&gt;"C:\Program Files\WindowsPowerShell\Modules\Azure\5.1.1\Automation\Microsoft.IdentityModel.Clients.ActiveDirectory.dll"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;$adalforms = &lt;/SPAN&gt;&lt;SPAN class="st0"&gt;"C:\Program Files\WindowsPowerShell\Modules\Azure\5.1.1\Networking\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="br0"&gt;[&lt;/SPAN&gt;&lt;SPAN class=""&gt;System.Reflection.Assembly&lt;/SPAN&gt;&lt;SPAN class="br0"&gt;]&lt;/SPAN&gt;&lt;SPAN class=""&gt;::&lt;/SPAN&gt;&lt;SPAN class="kw1"&gt;LoadFrom&lt;/SPAN&gt;&lt;SPAN class="br0"&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;$adal&lt;/SPAN&gt;&lt;SPAN class="br0"&gt;)&lt;/SPAN&gt;&lt;SPAN class=""&gt; | Out-Null&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="br0"&gt;[&lt;/SPAN&gt;&lt;SPAN class=""&gt;System.Reflection.Assembly&lt;/SPAN&gt;&lt;SPAN class="br0"&gt;]&lt;/SPAN&gt;&lt;SPAN class=""&gt;::&lt;/SPAN&gt;&lt;SPAN class="kw1"&gt;LoadFrom&lt;/SPAN&gt;&lt;SPAN class="br0"&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;$adalforms&lt;/SPAN&gt;&lt;SPAN class="br0"&gt;)&lt;/SPAN&gt;&lt;SPAN class=""&gt; | Out-Null&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;$redirectUri = &lt;/SPAN&gt;&lt;SPAN class="st0"&gt;"urn:ietf:wg:oauth:2.0:oob"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;$resourceAppIdURI = &lt;/SPAN&gt;&lt;SPAN class="st0"&gt;"&lt;A href="https://analysis.windows.net/powerbi/api" target="_blank"&gt;https://analysis.windows.net/powerbi/api&lt;/A&gt;"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;$authority = &lt;/SPAN&gt;&lt;SPAN class="st0"&gt;"&lt;A href="https://login.microsoftonline.com/common/oauth2/authorize" target="_blank"&gt;https://login.microsoftonline.com/common/oauth2/authorize&lt;/A&gt;"&lt;/SPAN&gt;&lt;SPAN class=""&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;$authContext = New-Object &lt;/SPAN&gt;&lt;SPAN class="st0"&gt;"Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext"&lt;/SPAN&gt;&lt;SPAN class=""&gt; -ArgumentList $authority&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;$UserCred = New-Object “Microsoft.IdentityModel.Clients.ActiveDirectory.UserCredential” -ArgumentList “UserName@domain.com“, “myPassword”&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;$authResult = $authContext.&lt;/SPAN&gt;&lt;SPAN class="kw1"&gt;AcquireTokenAsync&lt;/SPAN&gt;&lt;SPAN class="br0"&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;$resourceAppIdURI, $clientId, $UserCred&lt;/SPAN&gt;&lt;SPAN class="br0"&gt;)&lt;/SPAN&gt;&lt;SPAN class=""&gt;.Result&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;return $authResult&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="br0"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="co1"&gt;# Get the auth token from AAD&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;$token = GetAuthToken&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="co1"&gt;# Building Rest API header with authorization token&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;$authHeader = @&lt;/SPAN&gt;&lt;SPAN class="br0"&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="st0"&gt;'Content-Type'&lt;/SPAN&gt;&lt;SPAN class=""&gt;=&lt;/SPAN&gt;&lt;SPAN class="st0"&gt;'application/json'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="st0"&gt;'Authorization'&lt;/SPAN&gt;&lt;SPAN class=""&gt;=$token.&lt;/SPAN&gt;&lt;SPAN class="kw1"&gt;CreateAuthorizationHeader&lt;/SPAN&gt;&lt;SPAN class="br0"&gt;(&lt;/SPAN&gt;&lt;SPAN class="br0"&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="br0"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="co1"&gt;# properly format groups path&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;$groupsPath = &lt;/SPAN&gt;&lt;SPAN class="st0"&gt;""&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="kw1"&gt;if&lt;/SPAN&gt; &lt;SPAN class="br0"&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;$groupID -eq &lt;/SPAN&gt;&lt;SPAN class="st0"&gt;"me"&lt;/SPAN&gt;&lt;SPAN class="br0"&gt;)&lt;/SPAN&gt; &lt;SPAN class="br0"&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;$groupsPath = &lt;/SPAN&gt;&lt;SPAN class="st0"&gt;"myorg"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="br0"&gt;}&lt;/SPAN&gt;&lt;SPAN class=""&gt; else &lt;/SPAN&gt;&lt;SPAN class="br0"&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;$groupsPath = &lt;/SPAN&gt;&lt;SPAN class="st0"&gt;"myorg/groups/$groupID"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="br0"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="co1"&gt;# Refresh the dataset&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;$uri = &lt;/SPAN&gt;&lt;SPAN class="st0"&gt;"&lt;A href="https://api.powerbi.com/v1.0/$groupsPath/datasets/$datasetID/refreshes" target="_blank"&gt;https://api.powerbi.com/v1.0/$groupsPath/datasets/$datasetID/refreshes&lt;/A&gt;"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;Invoke-RestMethod -Uri $uri –Headers $authHeader –Method POST –Verbose&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="co1"&gt;# Check the refresh history&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;$uri = &lt;/SPAN&gt;&lt;SPAN class="st0"&gt;"&lt;A href="https://api.powerbi.com/v1.0/$groupsPath/datasets/$datasetID/refreshes" target="_blank"&gt;https://api.powerbi.com/v1.0/$groupsPath/datasets/$datasetID/refreshes&lt;/A&gt;"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;Invoke-RestMethod -Uri $uri –Headers $authHeader –Method GET –Verbose&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Dec 2019 13:34:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/programmatic-data-refresh-using-api/m-p/866534#M21650</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-12-05T13:34:08Z</dc:date>
    </item>
    <item>
      <title>Re: programmatic data refresh using api</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/programmatic-data-refresh-using-api/m-p/921383#M22207</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have written the follwing code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;function GetAuthToken&lt;BR /&gt;{&lt;BR /&gt;$adal = "C:\Program Files (x86)\Microsoft SDKs\Azure\Microsoft.IdentityModel.Clients.ActiveDirectory.dll"&lt;BR /&gt;$adalforms = "C:\Program Files (x86)\Microsoft SDKs\Azure\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll"&lt;BR /&gt;[System.Reflection.Assembly]::LoadFrom($adal) | Out-Null&lt;/P&gt;&lt;P&gt;[System.Reflection.Assembly]::LoadFrom($adalforms) | Out-Null&lt;/P&gt;&lt;P&gt;$redirectUri = "urn:ietf:wg:oauth:2.0:oob"&lt;/P&gt;&lt;P&gt;$resourceAppIdURI = "&lt;A href="https://analysis.windows.net/powerbi/api" target="_blank"&gt;https://analysis.windows.net/powerbi/api&lt;/A&gt;"&lt;/P&gt;&lt;P&gt;$authority = "&lt;A href="https://login.microsoftonline.com/common/oauth2/authorize" target="_blank"&gt;https://login.microsoftonline.com/common/oauth2/authorize&lt;/A&gt;";&lt;/P&gt;&lt;P&gt;$authContext = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext" -ArgumentList $authority&lt;/P&gt;&lt;P&gt;$UserCred = New-Object “Microsoft.IdentityModel.Clients.ActiveDirectory.&lt;STRONG&gt;UserCredential&lt;/STRONG&gt;” -ArgumentList “username@domain.com“, “pwd”&lt;/P&gt;&lt;P&gt;$authResult = $authContext.&lt;STRONG&gt;AcquireTokenAsync&lt;/STRONG&gt;($resourceAppIdURI, $clientId, $UserCred).Result&lt;/P&gt;&lt;P&gt;return $authResult&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get the following error:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;New-Object : Cannot find an overload for "UserCredential" and the argument count: "2".&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If i replace it with&amp;nbsp;&lt;STRONG&gt;UserPasswordCredential&amp;nbsp;&lt;/STRONG&gt;then it throws an error as:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Cannot find an overload for "AcquireTokenAsync" and the argument count: "3".&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have installed the latest version (5.2.6) of&amp;nbsp;Microsoft.IdentityModel.Clients.ActiveDirectory.dll and followed steps to register for ClientID in&amp;nbsp;&lt;A href="https://dev.powerbi.com/apps" target="_blank"&gt;https://dev.powerbi.com/apps&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestions how to correct it ?&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2020 15:38:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/programmatic-data-refresh-using-api/m-p/921383#M22207</guid>
      <dc:creator>prisam505</dc:creator>
      <dc:date>2020-02-04T15:38:37Z</dc:date>
    </item>
    <item>
      <title>Re: programmatic data refresh using api</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/programmatic-data-refresh-using-api/m-p/1209726#M24656</link>
      <description>&lt;P&gt;Is 'myorg' truly supposed to be part of the URL or is it standing for ones own comany id of some sort?&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jul 2020 16:51:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/programmatic-data-refresh-using-api/m-p/1209726#M24656</guid>
      <dc:creator>jbruns2020</dc:creator>
      <dc:date>2020-07-08T16:51:42Z</dc:date>
    </item>
  </channel>
</rss>

