Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

How to get the Service Api to use Azure AD

Vote:
 

Hello,

Episerver Admin login is successfully working using Azure AD, but I can't seem to get the Service Api to use it. I can only login to the Service Api by using the built in authentication. Is the Service Api even compatible with Azure AD? Any ideas on what I can try?

Thanks

#261142
Aug 26, 2021 16:01
Vote:
 

Yeah, out-of-the-box you will need to obtain a bearer token from ServiceAPI.

But since ServiceAPI is built on top of WebAPI, you can make it support other OWIN-based authentication methods.

The below code sample can be added to an initialization module.

// Make an initialization module, and decorate it with this attribute.
[ModuleDependency(typeof(EPiServer.ServiceApi.IntegrationInitialization))]

// Add this inside the Initialize method.
GlobalConfiguration.Configure(config =>
{
	config.Filters.Add(new HostAuthenticationFilter(DefaultAuthenticationTypes.ApplicationCookie));
});

DefaultAuthenticationTypes.ApplicationCookie refers to the default cookie-based ASP.Net Identity authentication. If you used another name in your Azure AD integration, use that instead.

#261241
Aug 28, 2021 15:51
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.