Anonymous api calls pre-login #508
Replies: 1 comment 1 reply
-
|
The The correct way to call an // When not using typed HTTP clients:
public class MyService(IHttpClientFactory httpClientFactory)
{
public async Task CallApi()
{
// Untyped HTTP client called "api_client"
var client = httpClientFactory.CreateClient("api_client");
await client.GetAsync("https://api.example.org/some/endpoint");
}
}
// When using typed HTTP clients:
public class MySecondService(ApiClient apiClient)
{
public async Task CallApi()
{
// Typed HTTP client
var client = httpClientFactory.CreateClient("api_client");
await client.GetSomeDataAsync();
}
}
public class ApiClient(HttpClient httpClient)
{
public async Task GetSomeDataAsync()
{
await client.GetAsync("https://api.example.org/some/endpoint");
}
}Whenever you resolve the appropriate What is strange, is the error message you're receiving: this error message indicates that you're using a client-credentials token client instead of a user access one as you're mentioning. Could you share how Please do obfuscate any authority URLs, client ID and client secrets, and sensitive scopes if there are any. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
We are using
AddUserAccessTokenHttpClientin our client app to create an httpClient for api calls. Some of these initial calls are to anonymous endpoints (minimal api, using.AllowAnonymous()extension). These work fine when everything is running off alocalhostwith distinct ports for the IS, the apis, and the client app, but are failing in deployed environments, with the errorError requesting access token for client Duende.TokenManagement.SchemeBasedClient:oidc. Error = unauthorized_client, Description: (null)which seems logical enough: can't get an access token if you're not yet authorized! Two-part question:localhostenvironment?Beta Was this translation helpful? Give feedback.
All reactions