December 2019
Intermediate to advanced
528 pages
11h 19m
English
The most obvious change here is that we need a new method. We referenced it earlier, and so the code won't compile as it is currently. If you select the method call that is unrecognized and use Ctrl-., you should see that the following method definition has been created in the interface (or you could simply copy it from here into IHttpClientHelper.cs):
Task<string> GetUserRole();
The implementation for this new method is in HttpClientHelper.cs and needs to look like this:
public async Task<string> GetUserRole(){ var userInfo = await _httpClient.GetUserInfoAsync(new UserInfoRequest() { Address = _discoveryResponse.UserInfoEndpoint, Token = _accessToken }); string role = userInfo.Claims.First(a => a.Type == JwtClaimTypes.Role).Value; ...Read now
Unlock full access