Skip to main content

Posts

Showing posts with the label Access Token

Hot Chocolate GraphQL Custom Authentication Series Using Pure Code First Technique - Part3 -Validating JWT Token And Different Authorization Techniques

Part2  we had generated a JWT access token for the user authentication. In this article, we are going to validate the JWT access token and also understand different techniques of Authorization. Install JwtBearer NuGet: To enable jwt token validation service we have to install JwtBearer NuGet. Package Manager Command: Install-Package Microsoft.AspNetCore.Authentication.JwtBearer -Version 5.0.4 .Net CLI Command: dotnet add package Microsoft.AspNetCore.Authentication.JwtBearer --version 5.0.4 Register JwtBearer Service: In the 'Startup.cs' file, we should register our JwtBearer validation service. Startup.cs: services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(options => { var tokenSettings = Configuration .GetSection("TokenSettings").Get<TokenSettings>(); options.TokenValidationParameters = new TokenValidationParameters { ValidIssuer = tokenSettings.Issuer, ValidateIssuer = true, ValidAudience = tokenSettings.Audienc

Part-2 Hot Chocolate GraphQL Validate JWT Access Token And Different Authorization Techniques

Part-1  completely discussed the steps to generate the access token in the GraphQL endpoint. Now in this article, our main goals are to validate the JWT access token and also we try to understand authorization techniques in GraphQL. Install JwtBearer Authentication NuGet: Let's install JwtBearer Authentication NuGet to configure JwtBearer services. .Net CLI Command: dotnet add package Microsoft.AspNetCore.Authentication.JwtBearer Package Manager Command: Install-Package Microsoft.AspNetCore.Authentication.JwtBearer Register JWT Validation Service: Now we need to register the JwtBearer service to validate our access token on the user sending the access token as an authorization header. Startup.cs: using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.IdentityModel.Tokens; services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(options => { options.TokenValidationParameters = new TokenValidationParameters { ValidIssuer = Con

Part-1 Hot Chocolate GraphQL JWT(JSON Web Token) Authentication - Generating User Login Access Token

In this article, we are going to implement a JWT authentication sample for the Hot Chocolate GraphQL endpoint. It's purely optional to implement JWT authentication in the GarphQL approach. Because .Net supports endpoint configuration for both normal .Net endpoint and GraphQL endpoint. While implementing GraphQL in your application and if you want to develop an authentication endpoint in the .Net approach there is no issue. But if you want to develop all endpoint in GraphQL including authentication that is also fine. So in this article, our goal is to create JWT authentication as a GraphQL endpoint. Create A .Net5 Web API Application: To understand the concept let's start our journey by creating a sample .Net5 Web API application. Recommended IDE for development are like Visual Studio 2019(Version 16.8.* for .Net5) or  Visual Studio Code . Install Hot Chocolate Library: Package Manager Command: Install-Package HotChocolate.AspNetCore -Version 11.0.2 .Net CLI Command: dotn

Part-1 VueJS JWT(JSON Web Token) Authentication(Access Token Implementation)

In this article, we are going to understand the steps for JWT(JSON Web Token) authentication. Here our main focus to fetch the JWT access token to make users log into our VueJS 3.0 application. For maintaining user info we will use Vuex state management. JWT Token: JSON Web Token is a digitally signed and secured token for user validation. The jwt is constructed with 3 informative parts: Header Payload Signature Create A VueJS 3.0 Sample Application: Let's begin by creating a VueJS 3.0 sample application. Command To Install Vue CLI Globally On Your System npm install -g @vue/cli Command To Create A Vue App: vue create your_app_name Required NPM Packages: Need to install the Vue routing library to configure routing into our application. Command To Install Vue Router Library(For Vue3.0) npm install vue-router@4 Need to install the Vuex Store library to configure state management to our application Command To Install Vuex Store Library(For Vue3.0) npm install vuex@next Install

Part-1 Ionic Angular JWT(JSON Web Token) Authentication(Access Token Implementation)

In this article, we are going to understand the implementation steps on Jwt authentication in Ionic5 angular application. Here we mainly concentrate on authenticated user access token. What is JSON Web Token?: JSON Web Token is a digitally signed and secured token for user validation. The jwt is constructed with 3 informative parts: Header Payload Signature Create A Sample Ionic Angular Application: Let's begin our journey by creating a sample Ionic Angular application where we are going to implement our JWT authentication. Command To Install Ionic CLI: npm install -g @ionic/cli Command To Create Ionic Tabs Structure APP: ionic start your_application_name tabs Command To Run Application: ionic serve Ionic Storage: The access token on receiving to our Ionic application we need to store it to use it in a subsequent request, the ideal choice for it to use Ionic Storage. Ionic storage provides an easy way to store key/value pairs and JSON objects. It has the capability of picking the