profile

Hi, I’m a creator

Different types of Authorization Grants and when to use them

Published 9 months ago • 2 min read

Hello there,

Hope you are doing good.

Token based Authentication is one of the most popular and widely used authentication and identity management systems used across the world.

It is simple, easy to integrate and makes user experience better.

Applications can decouple User Identity and Authentication layer to an externalized Authorization Server layer and delegate authentication to this server.

You will only enter credentials at a centralized Identity Provider site and the application accesses your profile or identity using a token that this Identity Provider issues to this application.

This token is application specific and one application cannot use this token from another application. This way you can ensure that your information is not being misused.

An Authorization Server or Secure Token Server is a component that is responsible for managing and issuing tokens to registered clients.

Identity Providers such as Google, Microsoft, Facebook etc. have their own Authorization servers that they have externalized for third-party app integrations.

You register your application as a client to the Authorization Server with details about what information your application expects after authentication (such as email, profile, etc.) what scopes it may ask for and the domain from which the request will be made.

On every request from this application, the Authorization Server validates these details and returns with the requested information.

Authorization Grant Types define the different ways in which a client application can request for tokens from an Authorization Server depending on the scenarios and use cases.

The following are the popular Authorization Grant Types -

Implicit: Used to retrieve tokens via browser. Client redirects the user to the authorization server where after consent the Server redirects back with the token without any back end call. This is not recommended. Authorization Code flow must be used instead.

Authorization Code: Used to retrieve tokens in the back channel instead of front-end via browser, now recommended for all client side applications. Client redirects the user to the Authorization Server, the user is authenticated and provides consent. The Authorization server redirects back to the client with an authorization code, followed by an API call to get the required token information.

Client Credentials: Used in App to App request scenarios, where an Application requests for Tokens from an Authorization Server with its Client Id and Client Secret. The Authorization Server returns back with Tokens. No consent or redirection is present and requests happen via back end API calls.

Resource Owner Password Credentials: Used in cases where an application impersonates a user and requests for tokens based on a username password combination.

Hybrid: Hybrid is an authentication flow where we combine two or more authentication flows to get multiple token results. possible examples are — authorization code with access token, authorization code with id token, access token and id token etc.

Refresh Token: This is used when clients need to request a new access token using a refresh token, which was obtained during the initial authentication.

You can find out more resources about Authorization and Implementing these Grant Types in ASP.NET Core here — https://referbruv.com/categories/identityserver4/

Follow on Medium - https://isriramkumarm.medium.com/different-types-of-authorization-grants-and-when-to-use-them-9c994a643770

I hope this content is useful to you. Subscribe to my Newsletter on Substack - https://codingramen.substack.com/

Have a great week.

Cheers

Ram

Hi, I’m a creator

Read more from Hi, I’m a creator

Hello there, Hope you are doing good. I wanted to share some interesting news to you. You want to add authentication to secure your resources, authorize access, implement CORS policies, enforce HTTPS, or even cache responses – you will add the respective built-in libraries to the web application. These are all exposed by the ASP.NET Core framework as Middleware – pieces of code blocks that are responsible for a single functionality. Announcing my new digital product - "How to work with...

10 months ago • 1 min read

Hello there, Hope you are doing good. This week, I want to introduce you to the 3 caching patterns that we generally use to implement Caching in our applications. We choose a caching pattern that best fits our application based on its behavior, business requirements and tolerance. The following are the 3 popular patterns used for caching in microservices. Cache-Aside The cache is lazy loaded with data only when needed and is not available in the cache. The microservice decides if the data...

10 months ago • 1 min read

Hello there, Hope you are doing good. This week I want to introduce you to Authorization and How to implement Authorization for a Web API in ASP.NET Core. .NET provides us with 3 ways of implementing Authorization depending on the requirement and the use-cases. In this article, I touch base on all the 3 mechanisms with explaining examples, so you don't need to look up for another content. Article Link - https://codingramen.com/blog/how-to-authorize-requests-in-asp-net-core-web-api/ I hope you...

10 months ago • 1 min read
Share this post