I’m running okta-aspnet-webforms-example.sln
I add a button.
I have a .net (core) 6.0 webapi, that is secured by okta. Its’ named SpnApi.
How can I call a method on SpnApi that has [Authorize]'d via Okta from that button.
I’m able to call one with [AllowAnonymous],
protected void Button1_Click( object sender, EventArgs e )
{
try
{
string buffer = string.Empty;
// Create an HttpClient instance
HttpClient client = new HttpClient();
var result = AsyncHelper.RunSync<string>( () => client.GetStringAsync( "http://localhost:44331/DoCdssLoginTestsAllowAnonymous?sAdName=bob.bob" ) );
TextBox1.Text = result;
}
catch ( Exception ex )
{
MsgBox(ex.ToString());
//throw;
}
}
but the other, I get (as expected) a 401, since no token is included. how do i modify the code above to call the secured api method?
Thanks,