Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
damienbod committed Nov 25, 2023
1 parent 4cef9e9 commit dcc91d7
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion BlazorAuth0Bff/Server/Services/MyApiServiceTwoClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public async Task<List<string>> GetServiceTwoApiData()
{
var client = _clientFactory.CreateClient();

client.BaseAddress = new Uri(_configurations["MyApiUrl"]);
client.BaseAddress = new Uri(_configurations["MyApiUrl"]!);

var access_token = await _auth0TokenApiService.GetApiToken(client, "ServiceTwoApi");

Expand Down
2 changes: 1 addition & 1 deletion BlazorAuth0Bff/Server/Services/MyApiUserOneClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public async Task<List<string>> GetUserOneApiData(string accessToken)
{
var client = _clientFactory.CreateClient();

client.BaseAddress = new Uri(_configurations["MyApiUrl"]);
client.BaseAddress = new Uri(_configurations["MyApiUrl"]!);

client.DefaultRequestHeaders.Authorization
= new AuthenticationHeaderValue("Bearer", accessToken);
Expand Down
4 changes: 2 additions & 2 deletions MyApi/Controllers/AzureADUserOneController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace MyApi.Controllers;
/// scope from App registration used to authorize.
/// </summary>
[SwaggerTag("API protected with Microsoft.Identity.Web and Microsoft Entra ID")]
[AuthorizeForScopes(Scopes = new string[] { "api://b2a09168-54e2-4bc4-af92-a710a64ef1fa/access_as_user" },
[AuthorizeForScopes(Scopes = ["api://b2a09168-54e2-4bc4-af92-a710a64ef1fa/access_as_user"],
AuthenticationScheme = "myADscheme")]
[Authorize(AuthenticationSchemes = "myADscheme")]
[ApiController]
Expand All @@ -28,6 +28,6 @@ public class AzureADUserOneController : ControllerBase
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
public IEnumerable<string> Get()
{
return new List<string> { "AzureADUser one data" };
return new List<string> { "Microsoft Entra ID user one data" };
}
}
4 changes: 2 additions & 2 deletions RazorMicrosoftEntraID/CallMyApiOne/MyApiOneService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ public async Task<List<string>> GetApiDataAsync()
var client = _clientFactory.CreateClient();

var scope = _configuration["MyApiOne:ScopeForAccessToken"];
var accessToken = await _tokenAcquisition.GetAccessTokenForUserAsync(new[] { scope });
var accessToken = await _tokenAcquisition.GetAccessTokenForUserAsync(new List<string> { scope! });

client.BaseAddress = new Uri(_configuration["MyApiOne:ApiBaseAddress"]);
client.BaseAddress = new Uri(_configuration["MyApiOne:ApiBaseAddress"]!);
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

Expand Down

0 comments on commit dcc91d7

Please sign in to comment.