Reputation: 579
I have followed below link for word add-in SSO: https://learn.microsoft.com/en-us/office/dev/add-ins/develop/create-sso-office-add-ins-aspnet
but As menitioned in the documentation add-in and API should be on same domain but in actual there are two projects one is add-in and another is API project,
As in sample, defined OpenIdConnectCachingSecurityTokenProvider,Startup.Auth in API project
Even I have added those files in AppStart, Startup.cs and values controller in same add-in project then also its not working. Is something I missing???
In sample provided, in add-in when I call ajax call url "/api/values" then its returning 404 i.e resource not found because add-in is running on https://localhost:44355 and WebAPI on http://localhost:33172/ Is this because of domain of add-in and webAPI project is diffrent as when I create any add-in project and running add-in project its run two application shown in IIS Express. So in your project also two projects running then how "api/values" will call webAPI controller of http://localhost:33172/ and as add-in is running in another domain i.e https://localhost:44355.
So How WebAPI and Add-in domain must be same As they are running on different urls such ashttp://localhost:33172/ and https://localhost:44355 respectively?? SO how could be same??
One more thing I observed that when I run your add-in project while loading add-in in word call comes into Configuration method of statrup.cs file and also in OpenIdConnectCachingSecurityTokenProvider method But in my add-in call not comes in these methods
How add-in will know to call this method of API project?? In my case it is not calling that method Even I was getting token for method Office.context.auth.getAccessTokenAsync method from where its acually getting token?
Upvotes: 0
Views: 216
Reputation: 9784
As you noted yourself, the documentation says that the add-in and your Web API have to be on the same fully qualified domain. You cannot have one at localhost:44355 and the other at localhost:33172. This is probably also why you are not seeing the call to OpenIdConnectCachingSecurityTokenProvider.
The Office.context.auth.getAccessTokenAsync method is getting the token from Azure Active Directory. This token gives Word access to the add-in at localhost:44355, but it does not give access to anything at localhost:33172.
Upvotes: 1