aspnet / JavaScriptServices

[Archived] This repository has been archived
Apache License 2.0
3.04k stars 519 forks source link

Authorize WebApi - Server PreRendering #616

Closed NicolasHumann closed 7 years ago

NicolasHumann commented 7 years ago

Hi,

My web apis are protected by OAuth and use the Authorize attribute. When I call my webapi in the constructor or in ngOnInit, Any credentials are passed in the request made by node in the rendering process.

How can I pass the token from the browser cookies to node ?

PS: I use the template ASP.NET Core Template Pack extension with angular2 / ts / webpack

Thanks !

SteveSandersonMS commented 7 years ago

You can pass through the cookie or other auth token data from your .NET code into your Node prerendering code, as described in the docs under the heading Passing data from .NET code into JavaScript code here.

You can then (via your TypeScript code) pass that auth token on to any services you call via Angular http methods.