Forum Discussion
Uploading PBIX File in C# sample (HELP!)
- 7 years ago
Hi brunozanoelo
You don't need dedicated capacity now. It has no connection with the autentication.
Are you running behind the code behind any proxy ? Which blocks your autentication ?
Can you try executing in Post man ?
Hi brunozanoelo
You don't really need redirect url for a native app. All you need to use the usercredential approach which is commented on the code you need to uncomment that. Because powerbi no longer support the client id with out Azure AD registration.
// create new ADAL authentication context
var authenticationContext =
new AuthenticationContext(ProgramConstants.AzureAuthorizationEndpoint);
//use authentication context to trigger user login and then acquire access token
//var userAuthnResult =
// authenticationContext.AcquireTokenAsync(ProgramConstants.PowerBiServiceResourceUri,
// ProgramConstants.ClientID,
// new Uri(ProgramConstants.RedirectUri),
// new PlatformParameters(PromptBehavior.Auto)).Result;
// use authentication context to trigger user sign-in and return access token
var userCreds = new UserPasswordCredential("[email protected]", "myEasyToCrackPassword");
var userAuthnResult = authenticationContext.AcquireTokenAsync(ProgramConstants.PowerBiServiceResourceUri,
ProgramConstants.ClientID,
userCreds).Result;
Update your username and password in the userpasswordcredentials
- brunozanoelo7 years agoPost Patron
Thank you so much for your reply.
I´ve changed my code as u said but now is giving me this error:System.AggregateException
HResult=0x80131500
Message=Um ou mais erros.
Source=mscorlib
StackTrace:
em System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
em System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
em System.Threading.Tasks.Task`1.get_Result()
em PbixInstallerForPowerBI.Program.AcquireAccessToken() em D:\Bitbucket\PowerBI\Integração REST\PbixInstallerForPowerBI-master\PbixInstallerForPowerBI\Program.cs:linha 54
em PbixInstallerForPowerBI.Program.Main() em D:\Bitbucket\PowerBI\Integração REST\PbixInstallerForPowerBI-master\PbixInstallerForPowerBI\Program.cs:linha 303Exceção interna 1:
AdalServiceException: AADSTS65001: The user or administrator has not consented to use the application with ID '75d071b1-378d-4f76-bb68-da4e033cf646' named 'instalador'. Send an interactive authorization request for this user and resource.
Trace ID: 20ec587e-39c6-4afa-acbb-67dfe8c9c800
Correlation ID: a7f7e02e-ffde-453b-b331-89c2e89a3601
Timestamp: 2019-08-14 17:32:02ZExceção interna 2:
AdalServiceException: Response status code does not indicate success: 400 (BadRequest).
What should be?
BEST regards- Jayendran7 years agoSolution Sage
Hi brunozanoelo
The admin needs to consent your application. You can do this from you Azure Active Directory for your application called instalador
Another little change in the code to force TLS1.2, pls update your code like below
System.Net.ServicePointManager.SecurityProtocol = System.Net.ServicePointManager.SecurityProtocol | System.Net.SecurityProtocolType.Tls12; var userCreds = new UserPasswordCredential("[email protected]", "myEasyToCrackPassword"); var userAuthnResult = authenticationContext.AcquireTokenAsync(ProgramConstants.PowerBiServiceResourceUri, ProgramConstants.ClientID, userCreds).Result;- brunozanoelo7 years agoPost Patron
Jayendran Thank you for the help. I really appreciate it.
It worked to authenticate but now I´m facing one problem in my workspace. I already set all the permissions to this app, including read/write workspaces.
Error (cannot find workspace)Workspace
Permissons
Any tip? I´m trying everything in Azure and nothing solve this problem.?
Warm Regards.