damienbod/AspNetCoreMvcAngular

WebAPI intergration scenario

sonphnt opened this issue · 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

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

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

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

@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

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

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.

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

Thank you!