Available as NuGet erl.AspNetCore.AgsToken.
This middelware will fetch an AGS access token and attach it to the incoming request.
Access tokens are cached for their lifetime and reused. Remember to include following NuGet packages.
public void ConfigureServices(IServiceCollection services)
{
services.AddOptions();
services.AddMemoryCache(); // caching of AGS tokens
// configuration: AGS token middelware
services.Configure<AgsOptions>(options =>
{
_configuration.GetSection("ArcGisServer").Bind(options);
});
}
public void Configure(IApplicationBuilder app)
{
app.UseMiddleware<AgsTokenMiddleware>();
}
Orginallly developed for proxying OAuth2 to AGS token using Microsoft.AspNetCore.Proxy.