Last post Jan 24, 2020 01:07 AM by Scblankenship
Nov 17, 2019 03:20 AM|The Rudi|LINK
I'm looking for some advice or confirmation that I am going down the right path.
I have a B2C directory that I will be using for my system. The system will consist of a WebAPI and a Blazer Server Side app. I'm using all the latest .net core 3.0 templates. Is my thinking correct? The webapi and blazor app are two seperate app registrations
in my b2c directory.
The Blazor app and the Webapi will both use Azure B2C for auth. What I'm trying to do is that once the user auths to the blazor app, when the user executes a function that calls the webapi, I want to use the logged in user's (in the blazor app) context
to call the webapi...
I got my webapi and my blazor app configured to use B2C with no issues... but there's a few things I need some direction on:
I'm looking at calling my webapi through something like this (Still playing with it so this might be totally wrong)
HttpClient client = new HttpClient();
var test4 = httpContextAccessor.HttpContext;
var authState = AuthenticationStateProvider.GetAuthenticationStateAsync();
var user = authState.Result.User;
//Looking at using something like this to get an access token....
//var token = user.Claims["access_token"];
Uri ServiceBaseUri = new Uri("https://mywebapi.com/");
myapp.server.api.swaggerClient t = new myapp.server.api.swaggerClient(ServiceBaseUri.ToString(), client);
string currentCount = t.WeatherForecastAsync("test123").Result;
Last question... Here I am declaring a new Httpclient... Blazor has it's own httpclient. How can I inject / reference it in a custom class to use the built in httpclient?
Jan 24, 2020 01:07 AM|Scblankenship|LINK