Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
yuliaria
Frequent Visitor

wstrust endpoint _not_found: WS-Trust endpoint not found in metadata document

 

Hi All,

 

I have a problem. I have two accounts, one is my company's account (which uses single sign on) and the other one is my personal account.

 

I already registered my app to Azure AD, and gave the same app permissions to both accounts. Including "Access the directory as the signed-in user".

 

When I use my company account, I keep getting this error when trying to get token (authenticationContext.AcquireTokenAsync): 

wstrust endpoint _not_found: WS-Trust endpoint not found in metadata document

 

But when I use my personal account, I don't get that error.

 

Would you guys please advise, why I keep getting that error? Any suggestion where should I start my investigation?

 

Thank you all.

 

Best regards,

Yuli Aria Winata

 

The following is my code.

Spoiler
private static UserPasswordCredential credential = null;
private static AuthenticationResult authenticationResult = null;
private static TokenCredentials tokenCredentials = null;
static void Main(string[] args)
{
	try
	{
		// Create a user password cradentials.
		credential = new UserPasswordCredential( "someusername@mycompany.com", "MyPasssword");

		// Authenticate using created credentials
		Authorize().Wait();

		using (var client = new PowerBIClient(new Uri("https://api.powerbi.com/"), tokenCredentials))
		{
			// TODO
		}
	}
	catch(Exception ex)
	{
		Console.ForegroundColor = ConsoleColor.Red;
		Console.WriteLine(ex.ToString());
		Console.ResetColor();
	}
}

private static Task Authorize()
{
	return Task.Run(async () => {
		authenticationResult = null;
		tokenCredentials = null;
		var authenticationContext = new AuthenticationContext( "https://login.windows.net/common/oauth2/authorize/" );

		authenticationResult = await authenticationContext.AcquireTokenAsync("https://analysis.windows.net/powerbi/api", "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx", credential);

		if (authenticationResult != null)
		{
			tokenCredentials = new TokenCredentials(authenticationResult.AccessToken, "Bearer");
		}
	});
}

 

2 REPLIES 2
v-micsh-msft
Employee
Employee

The error message should be related to AAD authentication.

"gave the same app permissions to both accounts"

Could you please explain more details about the company account and the personal account?

 

Your company account should be authenticated through the company Azure tenant, and I think your personal account is not able to access the resources within your company.

 

If the service works for your personal account, then please verify and make sure you have logged in with the proper account for the App you registered.

 

Regards,

Michael

 

Hi Michael,

 

Apologies, I think my explanation was confusing.

 

By having two accounts, I meant I have two different AADs. 

One is my Company AAD, and the other one is my Personal AAD.

 

My Company AAD gives the error, but My Personal AAD don't.

 

I'm not familiar with Azure. Would you please advise how can I give permissions to my Company AAD?

 

Thank you.

 

Best regards,

Yuli Aria Winata

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.