I also got same issue. For me user access token worked. rather than app access token.
public async Task<string> GetAccessToken()
{
if (_authToken == null)
{
var tenantId = Configuration.TenantId;
var clientId = Configuration.ClientId;
var authority = $"https://login.microsoftonline.com/{tenantId}";
var scopes = new string[] { "https://domain.sharepoint.com/.default" };
var cca = PublicClientApplicationBuilder.Create(clientId)
.WithRedirectUri("http://localhost")
.WithAuthority(new Uri($"https://login.microsoftonline.com/{tenantId}"))
.Build();
var result = await cca.AcquireTokenInteractive(scopes).ExecuteAsync();
return _authToken = result.AccessToken;
}
return _authToken;
}
But don't forget to add redirect URL in Azure. under Home>>App registartions>>App>>Authentication.