Skip to main content

Posts

Showing posts with the label Dotnet6

Part-2 Blazor WebAssembly Cookie Authentication With Facebook

In this article, we are going to implement Blazor WebAssembly cookie authentication with Facebook(external login provider). Click here for - Part-1 Blazor WebAssembly authentication with .net core cookie. Install Facebook NuGet In API Project: Let's install the Microsoft Facebook Authentication package. .NET CLI Command: dotnet add package Microsoft.AspNetCore.Authentication.Facebook --version 6.0.3 Package Manager: Install-Package Microsoft.AspNetCore.Authentication.Facebook -Version 6.0.3 Register API Wih Facebook: To enable Facebook authentication we have to register our API project with Facebook. So following are facebook registration steps. Step1: Go to the Facebook Developer page at "https://developers.facebook.com/apps/". Step2: Go to the 'My Apps' menu and click on the 'Create App' button. Step3: In the 'Create An App' section, choose the 'Consumer' option and then click on the 'Next' button. Step4: In the 'Detail

Part-1 Blazor WebAssembly Cookie Authentication[.NET 6]

In this article, we are going to authenticate our Blazor WebAssemably application with simple Asp.NetCore cookie. Targets Of Blazor WebAssembly Cookie Auth Series: Let's have look at this Blazor WebAssmbly series: Part -1 is simple asp.net core cookie authentication. Part-2 is cookie authentication with FaceBook. Part-3 is cookie authentication with Twitter. Part-4 is cookie authentication with Google. Part-5 is cookie authentication with Microsoft. Blazor WebAssembly Cookie Authentication Flow: We must have 2 applications 'Blazor WebAssembly Application'(which runs on the user browser), and 'Asp.Net Core API'(which runs on the server). Blazor WebAssembly requests the API for user authentication by sending the user credentials to API. For valid credentials, API generates auth cookie and sends it to the client application. So after successful authentication of every request from Blazor WebAssembly to API, the auth cookie will be attached to every subsequent request

Hot Chocolate GraphQL Pagination Using UseOffsetPaging Middleware[.NET6]

In this article, we are going to understand the GraphQL pagination using the 'UseOffsetPaging' middleware. UseOffsetPaging Middleware: Hot chocolate provides default pagination middleware that is 'UseOffsetPaging'. Simply applying 'UseOffsetPaging' on the resolver method will enable the pagination. This middleware implicitly reads the variables like 'skip' and 'take' from the request query and then generates the raw SQL query from the IQueriable. Create A .NET6 Web API Project: Let's create a .Net6 Web API sample application to accomplish our demo. We can use either Visual Studio 2022 or Visual Studio Code(using .NET CLI commands) to create any .NET6 application. For this demo, I'm using the 'Visual Studio Code'(using the .NET CLI command) editor. .NET CLI Command: dotnet new webapi -o Your_Project_Name Sample Table Data: Let's have a sample Todo table as shown. Setup EntityFramework Core Database Context: Let's

Part-5 Ocelot API Gateway For Microservices[.NET6 Microservice Series]

In this article, we are going to implement API Gateway for our microservices to define a unified URL with that all client applications can consume it instead of consuming individual URLs of the microservices. Part-4 Asynchronous Data Communication Between Microservices Using RabbitMQ Message Broker With MassTransit[.NET6 Microservice Series] Need Of API GateWay?: Consider our microservice where we have two microservice applications. The 'Manufacture.API' application runs at 'https://localhost:7132' and The 'SalesBusiness.API' runs at 'https://localhost:7456' so from this we can understand we have 2 different domains bound to our each microservices. So in the real-world application, we may deal with 10plus microservices base on our business. So handling or managing or consuming 10plus different domains by a client application is very hard. So to solve this problem API Gateway comes into the picture. So API Gateway is also a simple API project with its