Call Protected APIs from a Blazor Web App

Hi @LuckyWolf19,
To be honest, I’m unable to get these messages :thinking:
I’m using Edge 127.0.2651.74

Anyway, the authentication state in your Blazor application does not depend on third-party cookies, so that message is weird.

Also, the other message is weird too, since I assume you are using the HTTPS profile to access your Blazor app. In any case, the AspNetCore.Antiforgery is an ASP.NET Core builtin cookie, not an Auth0 cookie. See here to learn more.

Sorry if I can’t help more with these messages.

First like everyone I want to say, excellent article. I was able to follow along and make the changes and both internal and external work. I then decided since I will be using AWS Lambda / API, I thought I’d try basically the same thing except put the little bit of code in a lambda then add .JWT authentication to the API. I tested it with Postman, taking a token from the Test section in Auth0 API for it, so that works. But I think I do not have the paths just right. I named the api data just like the external api, but I get nada when I click the button. I did some debugging and know I’m getting the correct authentication token. I think it is in the path that gets generated, something is not quite right, any ideas?

After spending some time debugging, I know I am passing the token to the correct URL. But I am getting a 500 error submitting the request according to the developer tools in the browser. I think it means since the requests go through the server, my dev server?

OMG, which is what I yelled when I found it. I used Copilot, I tried all over the place to find the answer, and the two above posts. Finally got just the right question I think in Copilot, I.E. Assistant from Resharper, I kept at it saying this code returns a 500 error, and that Postman worked, it said, “Bearer” not “bearer”, oy vey, case messes with me again. I am posting this in case someone else runs into it.

1 Like

Hey @MickCG, sorry for being silent recently. I was away from the keyboard for a few days :slightly_smiling_face:

I’m happy you were able to solve your problem (well, actually Copilot did it :joy:).
To add some color to this story, looks like there is some confusion about the proper case of the “bearer” keyword: take a look here and here :slightly_smiling_face:

Now, I’m curious. I’ll investigate :slightly_smiling_face:

Thanks for getting back to me, now my next task to really get to the actual programming on my Blazor app how to distribute it on AWS. Which seems to be Elastic Beanstalk. But when I tried it from VS, the resulting website was not HTTPS? ROFL! I’m off and running looking for a good article on setting it all up!

Hey @MickCG, I just published a blog post inspired by your misadventure with the bearer scheme: :slightly_smiling_face:

BTW, Copilot was wrong :smirk: