cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
yuliaria Frequent Visitor
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 New Contributor
New Contributor

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

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

 

yuliaria Frequent Visitor
Frequent Visitor

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

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
October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Badges

Incoming: New and Improved Badges

Exciting news: We've given our badges an overhaul and added brand news ones.

Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Top Kudoed Authors
Users Online
Currently online: 254 members 2,623 guests
Please welcome our newest community members: