AspNetCoreMvcAngular icon indicating copy to clipboard operation
AspNetCoreMvcAngular copied to clipboard

WebAPI intergration scenario

Open sonphnt opened this issue 7 years ago • 7 comments

Hi @damienbod

Thanks for a great contribution. Do you think we can add a web api core project here? The flow is:

MVC Angular will be redirected to IdentityServer login page. After successful login there, you will be navigated back to MVC angular.

Angular app need to interact with WebApi to do CRUD function on data. How can we get a valid access token from MVC, so Angular can pass it to Webapi?

Thanks

sonphnt avatar May 10 '17 13:05 sonphnt

A valid access token is returned in the cookie. You could change the flow or the middleware if you want to use the cookie directly, or you could just use the cookie.

Greetings Damien

damienbod avatar May 13 '17 18:05 damienbod

Hi @damienbod

Is there any code showing the way get access token in cookies in Angular. And do we need any configuration between Angular and Webapi ?

Thanks

sonphnt avatar May 15 '17 08:05 sonphnt

@damienbod, it would be really appreciated if you could answer the above question from @sonphnt.

johnsonps08 avatar Jun 09 '17 14:06 johnsonps08

@johnsonps08 @sonphnt , sorry missed this. No the cookie is http only. If you require an access_token to access an API from a different server, you could use a different flow, or access the API from the server. I will look into this. I will check if access_token can be made public to the client, to access the API

damienbod avatar Jun 10 '17 20:06 damienbod

think this is possible using the connect/token API, will investigate

damienbod avatar Jun 10 '17 20:06 damienbod

Yes, something as we have 3 servers Angular-Webapi-IdentityServer. Firstly, Angular will be redirected to IdentityServer back and forth to authenticate first. WebAPI talk to IdentityServer in background somehow. And then Angular will request to WebApi to retrieve data after being authenticated at step 1.

That would be nice if we could have a project setup for this scenario.

sonphnt avatar Jun 12 '17 16:06 sonphnt

@damienbod were you ever able to investigate whether or not we can make a call out to the connect/token API?

Thank you!

ncalarco avatar Apr 11 '18 16:04 ncalarco