botauth icon indicating copy to clipboard operation
botauth copied to clipboard

[Authority] field ignored - Authentication Fails for enterprise tenant with BotAuth.AADv2

Open Zaid-Safadi opened this issue 7 years ago • 1 comments

I am building a bot App that connects to my enterprise O365 tenant. When using BotAuth.AADv2 to authenticate I get the a response from Azure that my app can't use the common endpoint and I should use my tenant endpoint.

I specified my tenant "Authority" endpoint in the "AuthenticationOptions" to be my tenant: https://login.microsoftonline.com/{tenantId}/oauth2/token but the authentication still fails

I traced the code and the problem is not passing the "Authority" parameter to the "ConfidentialClientApplication" in the MSALAuthProvider

I updated the following two lines to make it work: Line 57-58:

 ConfidentialClientApplication client = new ConfidentialClientApplication(authOptions.ClientId,
 **authOptions.Authority**, redirectUri.ToString(), new ClientCredential(authOptions.ClientSecret), 
tokenCache, null);

Line 67-68:

ConfidentialClientApplication client = new ConfidentialClientApplication(authOptions.ClientId, 
**authOptions.Authority**, authOptions.RedirectUrl, new ClientCredential(authOptions.ClientSecret), 
tokenCache, null);

I can submit a pull request if you like.

Zaid-Safadi avatar Mar 10 '18 16:03 Zaid-Safadi

Ah thanks for confirming this. Explains the issue I was having.

XVII avatar Apr 14 '18 06:04 XVII