If you're looking to use Amazon Cognito for authentication and authorization in your web or mobile app, you'll need to understand the different types of OAuth 2.0 grants supported by the service. In this blog post, we'll take a look at each of those grant types and explain how they work.
Amazon Cognito supports the following three types of OAuth 2.0 grants:
The Authorization Code Grant is a secure authorization method used to provide end-users with access tokens. It works by not exposing the access token, but rather providing an authorization code instead. This code is then used by the end user to request an access token from Amazon Cognito, which is then passed back to the application. This provides an additional layer of security, as the application never has direct access to the user's credentials.

Amazon Cognito's Implicit Grant is an OAuth2-based authorization flow that provides access to user pool resources without the need for additional authentication. It is designed to improve the user experience and reduce the number of requests to obtain an access token.
The Implicit Grant flow makes use of an id_token, which is a JSON Web Token (JWT) containing identity information about a user, such as their name or email address. This id_token is used in exchange for the desired resource, often times an API endpoint.
The Implicit Grant flow also allows for other types of tokens such as access tokens, refresh tokens and session tokens, depending on the application's requirements. Compared to Authorization Code Grant, Implicit Grant is less secure since it exposes user pool access tokens directly to end users. However, if Authorization Code Grant cannot be used then Implicit Grant can be beneficial due to its faster request time and improved user experience over Basic Authentication.

This specific grant is designed for machine-to-machine interactions; It is much simpler and more straightforward than other authorization flows, allowing machines to communicate securely without the need for user interaction.
With Amazon Cognito Client Credentials Grant, you can use two different types of authentication: public client authentication and confidential client authentication. When using public client authentication, developers don’t need to keep any secure information on the device. Instead, they are able to use a publicly available token issued by a third party such as AWS Identity Provider.
On the other hand, when using confidential client authentication, developers must store a secure client ID and secret on the device. This allows them to identify themselves to Amazon Cognito and receive an access token in return.
