Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredJoin us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.
Hello, I have a problem, with your explication on your API : "https://powerbi.microsoft.com/fr-fr/documentation/powerbi-developer-walkthrough-push-data-get-token/"
I can't have an Access Token, because I have meet two problems with you explication.
I'm waiting for you answer,
Sarah Q.
Solved! Go to Solution.
@SarahQUL wrote:
Hello, I have a problem, with your explication on your API : "https://powerbi.microsoft.com/fr-fr/documentation/powerbi-developer-walkthrough-push-data-get-token/"
I can't have an Access Token, because I have meet two problems with you explication.
- I can't install the package "Microsoft.IdentityModel.Clients.ActiveDirectory" with the version "2.21.301221612", because when I try to install this package, the console tell me: some of the package s that will be installed are incompatible with " .NetCoreApp, version = v1.1". But I can install the last version 3.13.9. I have search on your API, the Forums, and the Internet an explication but I haven't found any informations. I would like some explication and perhaps a solution.
- When I retrieve the Code on your page for "Visual Studio" , a can't use the methode: " String token = authContext.AcquireToken(ressourceUri, ClientID, newUri(redirectUri)).AccessToken; "
I suppose this is a problem with the version of the package I have install, but when I go on the API in order to found an other solution, I realise the documentation haven't the last version on the methods. The API are with the version 2.19.208020213. And I found the information are not very details. I don't found the help I search.
I'm waiting for you answer,
Sarah Q.
To get a token with the ADAL 3.13.9, try
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()
{
//The client id that Azure AD created when you registered your client app.
string clientID = "d9146xxxxxx946e8";
//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";
// 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;
return authContext.AcquireTokenAsync(resourceUri, clientID, new Uri(redirectUri), new PlatformParameters(0)).Result.AccessToken;
}
#endregion
}
}
@SarahQUL wrote:
Hello, I have a problem, with your explication on your API : "https://powerbi.microsoft.com/fr-fr/documentation/powerbi-developer-walkthrough-push-data-get-token/"
I can't have an Access Token, because I have meet two problems with you explication.
- I can't install the package "Microsoft.IdentityModel.Clients.ActiveDirectory" with the version "2.21.301221612", because when I try to install this package, the console tell me: some of the package s that will be installed are incompatible with " .NetCoreApp, version = v1.1". But I can install the last version 3.13.9. I have search on your API, the Forums, and the Internet an explication but I haven't found any informations. I would like some explication and perhaps a solution.
- When I retrieve the Code on your page for "Visual Studio" , a can't use the methode: " String token = authContext.AcquireToken(ressourceUri, ClientID, newUri(redirectUri)).AccessToken; "
I suppose this is a problem with the version of the package I have install, but when I go on the API in order to found an other solution, I realise the documentation haven't the last version on the methods. The API are with the version 2.19.208020213. And I found the information are not very details. I don't found the help I search.
I'm waiting for you answer,
Sarah Q.
To get a token with the ADAL 3.13.9, try
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()
{
//The client id that Azure AD created when you registered your client app.
string clientID = "d9146xxxxxx946e8";
//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";
// 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;
return authContext.AcquireTokenAsync(resourceUri, clientID, new Uri(redirectUri), new PlatformParameters(0)).Result.AccessToken;
}
#endregion
}
}
Every time I run my C# code to retrieve an access token. A modal dialog box pops up to enter logon credentials. I check the save credentials box, but every call is the same thing. How can you automate smething that pops up a modal dialog?
I recieve the token ok, but can I reuse that same token so the testing is not so aggrevating and time consuming?
Please help...
Thanks
Paul
Excuse me Eric, I try to implement your solution, But I have a new problem.
When I test your code I have a " System.AggregateException : 'One or mor errors occured' " that appeared.
But I don't know the C# and I can't solve this exception, Have you a solution at this exception?
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |