<?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: Get an authentication access token in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Get-an-authentication-access-token/m-p/1943115#M30392</link>
    <description>&lt;P&gt;I managed to get my access token by disabling MFA in AAD&lt;/P&gt;</description>
    <pubDate>Wed, 07 Jul 2021 13:09:51 GMT</pubDate>
    <dc:creator>rdc_green</dc:creator>
    <dc:date>2021-07-07T13:09:51Z</dc:date>
    <item>
      <title>Get an authentication access token</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Get-an-authentication-access-token/m-p/1933609#M30284</link>
      <description>&lt;P&gt;I have registered an app with Azure AD and now have an Application ID (&lt;A href="https://docs.microsoft.com/en-us/power-bi/developer/embedded/register-app?tabs=customers%2CAzure" target="_self"&gt;Register an Azure AD application to use with Power BI&lt;/A&gt;) i've now tried to complete step 2 of the process, which is to&amp;nbsp;&lt;A href="https://docs.microsoft.com/en-us/power-bi/developer/automation/walkthrough-push-data-get-token" target="_self"&gt;Get an authentiaction access token&lt;/A&gt;&amp;nbsp;I have downloaded Visual Studio 2019 onto my laptop and followed the steps in the documentation, but I get the following errors:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CS0246&amp;nbsp;&amp;nbsp;The type or namespace name 'Task&amp;lt;&amp;gt;' could not be found (are you missing a using directive or an assembly reference?)&amp;nbsp;&lt;/P&gt;&lt;P&gt;CS1503 Argument 3: cannot convert from 'System.Uri' to 'Microsoft.IdentityModel.Clients.ActiveDirectory.UserCredential'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can sort out the first error by changing the line below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;private static async Task&amp;lt;string&amp;gt; GetToken()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;to:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;private static string GetToken()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But i can't figure out how to correct the second issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Has anybody else come across this problem. Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jul 2021 15:49:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Get-an-authentication-access-token/m-p/1933609#M30284</guid>
      <dc:creator>rdc_green</dc:creator>
      <dc:date>2021-07-01T15:49:29Z</dc:date>
    </item>
    <item>
      <title>Re: Get an authentication access token</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Get-an-authentication-access-token/m-p/1937389#M30325</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/266604"&gt;@rdc_green&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Way 1:&lt;/P&gt;
&lt;P&gt;In the sample, steps 2 is using&lt;/P&gt;
&lt;PRE&gt;Install-Package Microsoft.IdentityModel.Clients.ActiveDirectory -Version 2.21.301221612&lt;/PRE&gt;
&lt;P&gt;Please make sure you have installed the package correctly.&lt;/P&gt;
&lt;P&gt;In the newer&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://blogs.technet.microsoft.com/enterprisemobility/2016/05/18/adal-net-v3-reaches-ga/" target="_self" rel="nofollow noopener noreferrer"&gt;ADAL v3&lt;/A&gt;, try this sample code.&lt;/P&gt;
&lt;PRE&gt;using Microsoft.IdentityModel.Clients.ActiveDirectory;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication32
{
    class Program
    { 
        static void Main(string[] args)
        {
            string token =  GetToken();
            Console.WriteLine(token);             
            Console.ReadLine();
             
        }

        #region Get an authentication access token
        private  static string GetToken()
        {
            // TODO: Install-Package Microsoft.IdentityModel.Clients.ActiveDirectory -Version 2.21.301221612
            // and add using Microsoft.IdentityModel.Clients.ActiveDirectory

            //The client id that Azure AD created when you registered your client app.
            string clientID = "3f756axxxxxxx3662e";

            //RedirectUri you used when you register your app.
            //For a client app, a redirect uri gives Azure AD more details on the application that it will authenticate.
            // You can use this redirect uri for your client app
            string redirectUri = "https://login.live.com/oauth20_desktop.srf";

            //Resource Uri for Power BI API
            string resourceUri = "https://analysis.windows.net/powerbi/api";

            //OAuth2 authority Uri
            string authorityUri = "https://login.windows.net/common/oauth2/authorize";

            //Get access token:
            // To call a Power BI REST operation, create an instance of AuthenticationContext and call AcquireToken
            // AuthenticationContext is part of the Active Directory Authentication Library NuGet package
            // To install the Active Directory Authentication Library NuGet package in Visual Studio,
            //  run "Install-Package Microsoft.IdentityModel.Clients.ActiveDirectory" from the nuget Package Manager Console.

            // AcquireToken will acquire an Azure access token
            // Call AcquireToken to get an Azure token from Azure Active Directory token issuance endpoint
            AuthenticationContext authContext = new AuthenticationContext(authorityUri);

            //string token = authContext.AcquireToken(resourceUri, clientID, new Uri(redirectUri)).AccessToken;
&lt;STRONG&gt;
            return   authContext.AcquireTokenAsync(resourceUri, clientID, new Uri(redirectUri), new PlatformParameters(0)).Result.AccessToken;
            &lt;/STRONG&gt; 
            
             
        }

        #endregion
    }
}&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Way 2. Or you can have a test on getting access token or generate embed token by postman.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Enter the same link and body in postman.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RicoZhou_0-1625470251261.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/546367iFBE8101EAAA51E8C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RicoZhou_0-1625470251261.png" alt="RicoZhou_0-1625470251261.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For reference:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://community.powerbi.com/t5/Developer/Power-BI-REST-API-using-postman-generate-embed-token/m-p/310054" target="_blank" rel="noopener"&gt;Solved: Power BI REST API using postman - generate embed t... - Microsoft Power BI Community&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best Regards,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Rico Zhou&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;If this post &lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider &lt;EM&gt;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&lt;/EM&gt; to help the other members find it more quickly.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jul 2021 07:31:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Get-an-authentication-access-token/m-p/1937389#M30325</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-07-05T07:31:36Z</dc:date>
    </item>
    <item>
      <title>Re: Get an authentication access token</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Get-an-authentication-access-token/m-p/1937527#M30332</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;@Anonymous&lt;/a&gt;&amp;nbsp;for your suggestions I have attempted both ways and have the following issues:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Way 1&lt;/P&gt;&lt;P&gt;I have the following 4 errors&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;EM&gt;Error CS0017 Program has more than one entry point defined. Compile with /main to specify the type that contains the entry point.&amp;nbsp;&lt;/EM&gt;&lt;/LI&gt;&lt;LI&gt;&lt;EM&gt;Error CS0103 The name 'token' does not exist in the current context ConsoleApp1&amp;nbsp;&lt;/EM&gt;&lt;/LI&gt;&lt;LI&gt;&lt;EM&gt;Error CS0103 The name 'GetToken' does not exist in the current context ConsoleApp1&amp;nbsp;&lt;/EM&gt;&lt;/LI&gt;&lt;LI&gt;&lt;EM&gt;Error CS7036 There is no argument given that corresponds to the required formal parameter 'customWebUi' of 'PlatformParameters.PlatformParameters(PromptBehavior, ICustomWebUi)'&lt;/EM&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Way 2&lt;/P&gt;&lt;P&gt;I have the following error due to MFA&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;EM&gt;"AADSTS50076:&amp;nbsp;Due&amp;nbsp;to&amp;nbsp;a&amp;nbsp;configuration&amp;nbsp;change&amp;nbsp;made&amp;nbsp;by&amp;nbsp;your&amp;nbsp;administrator,&amp;nbsp;or&amp;nbsp;because&amp;nbsp;you&amp;nbsp;moved&amp;nbsp;to&amp;nbsp;a&amp;nbsp;new&amp;nbsp;location,&amp;nbsp;you&amp;nbsp;must&amp;nbsp;use&amp;nbsp;multi-factor&amp;nbsp;authentication&amp;nbsp;to&amp;nbsp;access&amp;nbsp;'00000009-0000-0000-c000-000000000000'.\r\nTrace&amp;nbsp;ID:&amp;nbsp;1134cdb0-67cf-4721-8611-15879e9fef00\r\nCorrelation&amp;nbsp;ID:&amp;nbsp;56e71b1d-a011-4451-b385-87af8e3874c7\r\nTimestamp:&amp;nbsp;2021-07-05&amp;nbsp;08:11:03Z",&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Do you have any suggestions to fix either of these ways?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thank you&lt;/DIV&gt;&lt;DIV&gt;Richard&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jul 2021 08:17:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Get-an-authentication-access-token/m-p/1937527#M30332</guid>
      <dc:creator>rdc_green</dc:creator>
      <dc:date>2021-07-05T08:17:13Z</dc:date>
    </item>
    <item>
      <title>Re: Get an authentication access token</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Get-an-authentication-access-token/m-p/1939664#M30352</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/266604"&gt;@rdc_green&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Please try below steps to fix Way 2:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1.Login as a tenant admin to &lt;A href="https://portal.azure.com" target="_blank" rel="noopener"&gt;https://portal.azure.com&lt;/A&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2.Open the registration for your app in the&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3.Go to Settings then Required Permissions&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;4.Press the Grant Permissions button&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Note: If you are not a tenant admin, you cannot give admin consent&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You may try the solutions provided in similar&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://github.com/Azure-Samples/active-directory-angularjs-singlepageapp-dotnet-webapi/issues/19" target="_blank" rel="noopener"&gt;GitHub issue&lt;/A&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best Regards,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Rico Zhou&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;If this post &lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider &lt;EM&gt;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&lt;/EM&gt; to help the other members find it more quickly.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jul 2021 09:30:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Get-an-authentication-access-token/m-p/1939664#M30352</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-07-06T09:30:46Z</dc:date>
    </item>
    <item>
      <title>Re: Get an authentication access token</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Get-an-authentication-access-token/m-p/1942849#M30385</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&lt;/a&gt;&amp;nbsp;i've done the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Home/App Registrations/{App Name}&lt;/P&gt;&lt;P&gt;API Permissions&lt;/P&gt;&lt;P&gt;Grant Admin Consent for {Directory}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Result - '&lt;SPAN&gt;Successfully granted admin consent for the requested permissions'&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I've tried the following in Postman again with the same result:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;client_id - {Application (client) ID}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;grant_type - password&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;resource -&amp;nbsp;&lt;A href="https://analysis.windows.net/powerbi/api" target="_blank" rel="noopener"&gt;https://analysis.windows.net/powerbi/api&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;username - {my username}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;password - {my password}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In 'API Permissions' I have 'Azure Active Directory Graph' and 'Power BI Service'. Am I missing any other permissions?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jul 2021 11:56:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Get-an-authentication-access-token/m-p/1942849#M30385</guid>
      <dc:creator>rdc_green</dc:creator>
      <dc:date>2021-07-07T11:56:15Z</dc:date>
    </item>
    <item>
      <title>Re: Get an authentication access token</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Get-an-authentication-access-token/m-p/1943115#M30392</link>
      <description>&lt;P&gt;I managed to get my access token by disabling MFA in AAD&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jul 2021 13:09:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Get-an-authentication-access-token/m-p/1943115#M30392</guid>
      <dc:creator>rdc_green</dc:creator>
      <dc:date>2021-07-07T13:09:51Z</dc:date>
    </item>
  </channel>
</rss>

