3

I am able to authenticate a user when working locally, using the line

AuthenticationResult result = context.AcquireToken(resource,clientID, returnURI, PromptBehavior.Always);

Locally, I get the signin screen and the UserInfo.

When I publish the web app to Azure, the code above fails with this error

"Error HRESULT E_FAIL has been returned from a call to a COM component"

[COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.]

Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext.RunAsyncTask(Task`1 task) +89

What causes this? I am publishing to the shared site (eg xxx.azurewebsites.net) -- so I don't have access to the server machine to make any changes --- beyond using the portal.

The code works as expected locally.

Also the javascript version (ADAL.js) works using the same tenant, clientID and returnURI

Andro
  • 2,232
  • 1
  • 27
  • 40

1 Answers1

0

The token acquisition flow you are performing is meant to be ran on a desktop application, not a web one. The dialog that comes out on your desktop is driven by your local process and the existence of a local windows session. It cannot work within one web application, given that there is no windows session and the process is running elsewhere on a server machine. Please refer to our samples to understand how to acquire tokens from a web app, anything with "openid" or "oauth" from https://github.com/AzureADsamples will work.

vibronet
  • 7,364
  • 2
  • 19
  • 21