Implement API Key Authentication in ASP.NET Core Web API
ฝัง
- เผยแพร่เมื่อ 14 ก.พ. 2024
- ►► Master Web API development Best Practices: bit.ly/3TnqoFQ
►► Build great web apps in Blazor WebAssembly: bit.ly/437g87T
►► Support us on Patreon and get the source code: / codemaze
In this video, I’ll show you different ways to implement API key authentication in the .NET Web API project.
When we use the API key for the authentication, there are Different Ways of Passing it in a Request
We can use:
-Query Parameters
-Request Body
-Request Headers
In this video, I will only use the Headers option to pass the API key to the web API.
Besides the different ways to pass the API key to an endpoint, there are also different approaches to implementing API key authentication in ASP.NET Core. We can use:
-Custom Attribute
-Custom Middleware
-Endpoint filters with minimal APIs and
-Policy-based Authorization
I will show you all these approaches in this video.
LINKS MENTIONED IN THE VIDEO
►► Different Ways to Pass Parameters in .NET: • Different Ways to Pass...
FOLLOW US ON SOCIAL MEDIA!
►► / marinko-spasojevic
►► / codemazeblog
►► / codemazeblog
Thank you all for watching and for your support.
►► If you want to master Web API development using best practices, check out our Web API book: bit.ly/3x75ZMM
►► Also, to build great full-stack apps with Blazor, check out our course: bit.ly/3Pw3Y33
Awesome!!!
Thanks a lot.
Awesome video. Can it be possible to pass the api key as bearer tokens on the authorization header instead of the x-api-key header during the request? Thank you
Hi. Thank you for watching and for the kind words. Regarding your question. Yes, you can do that and for that I would use the Policy-based auth. Then inside the Authorization header of the Postman, you can send it using two ways. Either as a bearer token - but keep in mind that the header name is different and the "Bearer" will be appended to your token. Or, you can send it as an API Key (also inside the authorization header), and then you can provide the header name and the content of the API key.
@@CodeMaze Thank you
Is the source code on github? Link?
Hi. All the source code for each video with some other benefits are part of the patreon package. The link is in a description of the video.