I am using the EpiServer Service API and Content Delivery API. I want to use both Authorization, so I added the following code in my Startup.cs class.
app.UseServiceApiIdentityTokenAuthorization<ApplicationUserManager<ApplicationUser>, ApplicationUser>();app.UseContentApiIdentityOAuthAuthorization<ApplicationUserManager<ApplicationUser>, ApplicationUser>();
If I call the Auth token endpoints to generate the Tokens both works.
POST /api/episerver/auth/token Returns OK (ContentDelivery API)
POST /episerverapi/token Returns OK (EPiServer Service API)
When I make a call to the Content Delivery Endpoint, it works, I get my data back.
BUT when I make a call to the Service API, I am getting the following exception.
i have the same issue.... any dev/fix on this?Thanks
Hi, I know it is quite a late answer, but hope that it will help other people that have the same issue.
Basically, both UseServiceApiIdentityTokenAuthorization() of ServiceApi and UseContentApiIdentityOAuthAuthorization() of ContentDeliveryApi use the OWIN OAuthAuthorizationServerProvider under the hood. So if you register both methods, OWIN will throw an exception because of duplicated OAuth provider.
However, because ServiceApi and ContentDeliveryApi both use OWIN OAuth middleware so you really do not need to register both methods. Just use whichever method you prefer (for example: UseServiceApiIdentityTokenAuthorization()) and retrieve the token. After that, you should be able to use this token to authenticate with both ServiceApi and ContentDeliveryApi. Just make sure that your user has sufficient privileges to access both APIs.