{"id":2405,"date":"2025-07-01T07:19:21","date_gmt":"2025-07-01T07:19:21","guid":{"rendered":"https:\/\/200oksolutions.com\/blog\/?p=2405"},"modified":"2025-12-04T07:44:03","modified_gmt":"2025-12-04T07:44:03","slug":"aws-cognito-integration-with-laravel-application","status":"publish","type":"post","link":"https:\/\/www.200oksolutions.com\/blog\/aws-cognito-integration-with-laravel-application\/","title":{"rendered":"AWS COGNITO INTEGRATION WITH LARAVEL APPLICATION"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\"><strong>PRE-REQUISITES :<\/strong><\/h2>\n\n\n\n<p>Amazon Cognito User Pool has already been set up.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>HOW TO USE COGNITO WITH LARAVEL APPLICATION?<\/strong><\/h3>\n\n\n\n<p>Step 1: Click on the user pool and store a few details in the Laravel .env file of your project<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img fetchpriority=\"high\" decoding=\"async\" width=\"624\" height=\"308\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Picture1-1.webp\" alt=\"Laravel .env file configured with AWS Cognito credentials\" class=\"wp-image-2414\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Picture1-1.webp 624w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Picture1-1-300x148.webp 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"624\" height=\"310\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Picture2-1.webp\" alt=\"AWS Cognito user pool configuration panel\" class=\"wp-image-2415\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Picture2-1.webp 624w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Picture2-1-300x149.webp 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/figure>\n\n\n\n<p><br><strong>AWS_USER_POOL_ID = your-account-user-pool-id<\/strong><br><strong>AWS_USER_POOL_REGION = your-account-region<\/strong><br><br>Click on app clients and get the following details<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"624\" height=\"304\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Picture3-1.webp\" alt=\"App client ID and secret configuration in AWS Cognito\" class=\"wp-image-2416\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Picture3-1.webp 624w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Picture3-1-300x146.webp 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/figure>\n\n\n\n<p><br><strong>AWS_APP_CLIENT_ID = your-app-client-id<\/strong><br><strong>AWS_APP_CLIENT_SECRET_ID = your-app-client-secret-id<\/strong><br><br>Step 2: Return to the AWS home console and select Security Credentials.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"624\" height=\"304\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Picture4-1.webp\" alt=\"AWS security credentials panel for generating access keys\" class=\"wp-image-2417\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Picture4-1.webp 624w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Picture4-1-300x146.webp 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/figure>\n\n\n\n<p><br>Step 3: Click on Create Access Key<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"624\" height=\"285\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Picture5-1.webp\" alt=\"Access key creation window in AWS IAM console\" class=\"wp-image-2419\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Picture5-1.webp 624w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Picture5-1-300x137.webp 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/figure>\n\n\n\n<p><br>Step 4: After <strong>downloading <\/strong>and <strong>storing <\/strong>the keys in<strong>.csv format<\/strong>, add them to the project&#8217;s <strong>env <\/strong>file, which already has the <strong>AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY<\/strong> parameters by default. You should also comment out the <strong>AWS_DEFAULT_REGION<\/strong> parameter.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"624\" height=\"238\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Picture7.webp\" alt=\"Enabling custom authentication flows in AWS Cognito app client\" class=\"wp-image-2421\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Picture7.webp 624w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Picture7-300x114.webp 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/figure>\n\n\n\n<p><br>Step 5: To add any of the authentication flows labeled ALLOW_USER_PASSWORD_AUTH, ALLOW_ADMIN_USER_PASSWORD_AUTH, or ALLOW_CUSTOM_AUTH, click the Edit button on the app client. For the sake of illustration, we are currently choosing each one.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"624\" height=\"260\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Picture8.webp\" alt=\"AWS Lambda create function form with runtime language selection\" class=\"wp-image-2422\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Picture8.webp 624w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Picture8-300x125.webp 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/figure>\n\n\n\n<p>Step 6: Use the AWS console&#8217;s search box to look up Lambda.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"624\" height=\"299\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Picture9.webp\" alt=\"Python code editor in AWS Lambda for user verification logic\" class=\"wp-image-2423\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Picture9.webp 624w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Picture9-300x144.webp 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/figure>\n\n\n\n<p><br>Step 7: Click on the Create function button which will show this page.<\/p>\n\n\n\n<p>Enter the function name of your choice.<\/p>\n\n\n\n<p>Select run-time language or the language function would be written in. For now, we are choosing python and then click on create function.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"624\" height=\"285\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Picture10.webp\" alt=\"Configuring AWS Cognito Lambda pre-sign-up trigger\" class=\"wp-image-2425\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Picture10.webp 624w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Picture10-300x137.webp 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/figure>\n\n\n\n<p><br><br><br>Step 8:  You will be redirected to this page<\/p>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"821\" height=\"407\" data-id=\"2428\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step8_Image1.jpg\" alt=\"AWS IAM policy creation panel for Cognito user pool permissions\" class=\"wp-image-2428\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step8_Image1.jpg 821w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step8_Image1-300x149.jpg 300w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step8_Image1-768x381.jpg 768w\" sizes=\"(max-width: 821px) 100vw, 821px\" \/><\/figure>\n<\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"810\" height=\"386\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step8_Image2.webp\" alt=\"Adding user pool ARN to IAM policy for access control\" class=\"wp-image-2429\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step8_Image2.webp 810w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step8_Image2-300x143.webp 300w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step8_Image2-768x366.webp 768w\" sizes=\"(max-width: 810px) 100vw, 810px\" \/><\/figure>\n\n\n\n<p>To make the function useable, add the code below to the lambda_function.py file and click deploy.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import json\n\ndef lambda_handler(event, context):\n    event&#91;'response']&#91;'autoConfirmUser'] = True\n    event&#91;'response']&#91;'autoVerifyEmail'] = True\n    return event<\/code><\/pre>\n\n\n\n<p><br>Step 9:  Go back to the AWS Cognito console home, then click on &#8220;Extensions&#8221;, and select &#8220;Add Lambda Trigger&#8221;.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"741\" height=\"380\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step9_Image1.webp\" alt=\"Attaching custom IAM policy to AWS Lambda execution role\" class=\"wp-image-2430\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step9_Image1.webp 741w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step9_Image1-300x154.webp 300w\" sizes=\"(max-width: 741px) 100vw, 741px\" \/><\/figure>\n\n\n\n<p>Step 10: Set up the Lambda Trigger<\/p>\n\n\n\n<p>In this step, we\u2019ll use the <strong>sign-up trigger<\/strong> because we want the Lambda function to execute during the user sign-up process.<\/p>\n\n\n\n<p>Specifically, we are using a <strong>pre-sign-up trigger<\/strong>, which means the Lambda function will run <em>before<\/em> the user is registered in AWS Cognito.<\/p>\n\n\n\n<p>You can choose a different trigger type based on your specific requirements.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"827\" height=\"549\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step10_Image1.webp\" alt=\"Installing AWS SDK and Firebase JWT with Composer in Laravel\" class=\"wp-image-2431\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step10_Image1.webp 827w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step10_Image1-300x199.webp 300w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step10_Image1-768x510.webp 768w\" sizes=\"(max-width: 827px) 100vw, 827px\" \/><\/figure>\n\n\n\n<p><br>Select the appropriate Lambda function you created earlier and click on<br><strong>&#8220;Add Lambda Trigger&#8221;<\/strong><br>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"832\" height=\"303\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step10_Image2.webp\" alt=\"Laravel controller handling AWS Cognito registration and login\" class=\"wp-image-2432\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step10_Image2.webp 832w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step10_Image2-300x109.webp 300w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step10_Image2-768x280.webp 768w\" sizes=\"(max-width: 832px) 100vw, 832px\" \/><\/figure>\n\n\n\n<p>Step 11: Now, search for<strong> IAM<\/strong> in the AWS Console search bar<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"833\" height=\"403\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step11_Image1.webp\" alt=\"Laravel service class integrating AWS Cognito SDK\" class=\"wp-image-2433\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step11_Image1.webp 833w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step11_Image1-300x145.webp 300w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step11_Image1-768x372.webp 768w\" sizes=\"(max-width: 833px) 100vw, 833px\" \/><\/figure>\n\n\n\n<p><br>Step 12:Click on it and go to the Policies section<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"829\" height=\"420\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step12_Image1-1.webp\" alt=\"Successful user registration response from AWS Cognito in Postman\" class=\"wp-image-2435\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step12_Image1-1.webp 829w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step12_Image1-1-300x152.webp 300w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step12_Image1-1-768x389.webp 768w\" sizes=\"(max-width: 829px) 100vw, 829px\" \/><\/figure>\n\n\n\n<p>Click on create policy button.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"833\" height=\"401\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step12_Image2.webp\" alt=\"Access token and refresh token returned from AWS Cognito login\" class=\"wp-image-2436\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step12_Image2.webp 833w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step12_Image2-300x144.webp 300w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step12_Image2-768x370.webp 768w\" sizes=\"(max-width: 833px) 100vw, 833px\" \/><\/figure>\n\n\n\n<p>Choose a service named Cognito user pool in the below given image<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"822\" height=\"282\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step12_Image3.webp\" alt=\"Fetching user attributes from AWS Cognito using access token\" class=\"wp-image-2437\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step12_Image3.webp 822w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step12_Image3-300x103.webp 300w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step12_Image3-768x263.webp 768w\" sizes=\"(max-width: 822px) 100vw, 822px\" \/><\/figure>\n\n\n\n<p>Select the checkbox<\/p>\n\n\n\n<p>Here, we have provided all the permissions to the policy we are creating.<\/p>\n\n\n\n<p>You can choose permissions as per your requirement. Then you need not click on the Checkbox Which provides all the permissions to the policy.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"811\" height=\"471\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step12_Image4.webp\" alt=\"Logout confirmation response from AWS Cognito\" class=\"wp-image-2438\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step12_Image4.webp 811w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step12_Image4-300x174.webp 300w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step12_Image4-768x446.webp 768w\" sizes=\"(max-width: 811px) 100vw, 811px\" \/><\/figure>\n\n\n\n<p><br>Go to cognito console and fetch the arn for your user pool and add it in the Resources section of the policy being created by clicking<br><strong>Add ARNs<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"833\" height=\"423\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step12_Image5.webp\" alt=\"\" class=\"wp-image-2439\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step12_Image5.webp 833w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step12_Image5-300x152.webp 300w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step12_Image5-768x390.webp 768w\" sizes=\"(max-width: 833px) 100vw, 833px\" \/><\/figure>\n\n\n\n<p><br>Add your copied ARN in the field named<strong> resource arn.<\/strong> Also when add arn is clicked it will open this box<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"839\" height=\"357\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step12_Image6.webp\" alt=\"\" class=\"wp-image-2440\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step12_Image6.webp 839w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step12_Image6-300x128.webp 300w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step12_Image6-768x327.webp 768w\" sizes=\"(max-width: 839px) 100vw, 839px\" \/><\/figure>\n\n\n\n<p>Then Click next<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"664\" height=\"338\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step12_Image7.webp\" alt=\"\" class=\"wp-image-2441\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step12_Image7.webp 664w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step12_Image7-300x153.webp 300w\" sizes=\"(max-width: 664px) 100vw, 664px\" \/><\/figure>\n\n\n\n<p><br>Add the policy name and description<strong> (optional)<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"828\" height=\"428\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step12_Image8.webp\" alt=\"\" class=\"wp-image-2443\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step12_Image8.webp 828w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step12_Image8-300x155.webp 300w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step12_Image8-768x397.webp 768w\" sizes=\"(max-width: 828px) 100vw, 828px\" \/><\/figure>\n\n\n\n<p>Then click on create policy <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"662\" height=\"383\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/07\/Step12_Image9.jpg\" alt=\"\" class=\"wp-image-2465\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/07\/Step12_Image9.jpg 662w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/07\/Step12_Image9-300x174.jpg 300w\" sizes=\"(max-width: 662px) 100vw, 662px\" \/><\/figure>\n\n\n\n<p><br>After that Search in the search bar for the policy name, click it and go to Attach entities<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"755\" height=\"391\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step12_Image10.webp\" alt=\"\" class=\"wp-image-2445\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step12_Image10.webp 755w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step12_Image10-300x155.webp 300w\" sizes=\"(max-width: 755px) 100vw, 755px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"788\" height=\"388\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step12_Image11.webp\" alt=\"\" class=\"wp-image-2446\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step12_Image11.webp 788w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step12_Image11-300x148.webp 300w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step12_Image11-768x378.webp 768w\" sizes=\"(max-width: 788px) 100vw, 788px\" \/><\/figure>\n\n\n\n<p>Click on attach and add the role of your lambda function<br><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"806\" height=\"263\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step12_Image12.webp\" alt=\"\" class=\"wp-image-2447\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step12_Image12.webp 806w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step12_Image12-300x98.webp 300w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step12_Image12-768x251.webp 768w\" sizes=\"(max-width: 806px) 100vw, 806px\" \/><\/figure>\n\n\n\n<p>Then click on attach policy.<\/p>\n\n\n\n<p>Step 13: Go to roles section and you will be able to see the policies attached to your roles of lambda function.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"825\" height=\"381\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step13_Image1.webp\" alt=\"\" class=\"wp-image-2448\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step13_Image1.webp 825w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step13_Image1-300x139.webp 300w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step13_Image1-768x355.webp 768w\" sizes=\"(max-width: 825px) 100vw, 825px\" \/><\/figure>\n\n\n\n<p><br><br>Step 14: Add required Packages<br>a. Add aws sdk for php using command <strong>composer require aws\/aws-sdk-php<\/strong><br>b. Add Firebase jwt token sdk for php by using command <strong>composer require firebase\/php-jwt.<\/strong><\/p>\n\n\n\n<p>Step 15: Create a controller file.<br>Demo controller file code:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n\nnamespace App\\Http\\Controllers\\Cognito;\n\nuse App\\Http\\Controllers\\Controller;\nuse Illuminate\\Http\\Request;\nuse App\\Services\\CognitoAuthService;\n\nclass CognitoAuthController extends Controller\n{\n    \/\/\n    protected $cognitoAuth;\n\n    public function __construct(CognitoAuthService $cognitoAuth)\n    {\n        $this-&gt;cognitoAuth = $cognitoAuth;\n    }\n\n    public function register(Request $request)\n    {\n        $request-&gt;validate(&#91;\n            'name' =&gt; 'required|string|max:255',\n            'email' =&gt; 'required|string|email|max:255|unique:users',\n            'password' =&gt; 'required|string|min:6|confirmed',\n        ]);\n\n        return response()-&gt;json($this-&gt;cognitoAuth-&gt;registerUser(\n            $request-&gt;name,\n            $request-&gt;email,\n            $request-&gt;password\n        ));\n    }\n\n    public function login(Request $request)\n    {\n        \/\/ Validate the request input\n        $request-&gt;validate(&#91;\n            'email' =&gt; 'required|email',\n            'password' =&gt; 'required|string|min:6',\n        ]);\n    \n        \/\/ Call the service method with extracted email &amp; password\n        return $this-&gt;cognitoAuth-&gt;loginUser($request-&gt;email, $request-&gt;password);\n    }\n    \n    public function user(Request $request)\n    {\n        $accessToken = $request-&gt;header('Authorization');\n\n        if (!$accessToken) {\n            return response()-&gt;json(&#91;'error' =&gt; 'Token missing'], 401);\n        }\n\n        return response()-&gt;json($this-&gt;cognitoAuth-&gt;getUser(str_replace('Bearer ', '', $accessToken)));\n    }\n\n\n    public function logout(Request $request)\n    {\n        $accessToken = $request-&gt;header('Authorization');\n        \/\/dd($accessToken);\n        if (strpos($accessToken, 'Bearer ') === 0) {\n            $accessToken = substr($accessToken, 7); \/\/ Remove \"Bearer \" prefix\n        }\n        return response()-&gt;json($this-&gt;cognitoAuth-&gt;logoutUser($accessToken));\n    }\n}<\/code><\/pre>\n\n\n\n<p><br>Step 16: Create a Service Class<br>Demo Service Class code:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;? php\n\nnamespace App\\Services;\n\nuse Aws\\CognitoIdentityProvider\\CognitoIdentityProviderClient;\nuse Exception;\nuse Illuminate\\Http\\Request;\n\nclass CognitoAuthService {\n    protected $client;\n\n    public function __construct() {\n        $this -&gt; client = new CognitoIdentityProviderClient(&#91;\n            'version' =&gt; 'latest',\n            'region' =&gt; env('AWS_COGNITO_REGION'),\n        ]);\n    }\n\n    \/**\n     * Generate Secret Hash for Cognito authentication.\n     *\/\n    private function getSecretHash($username) {\n        return base64_encode(\n            hash_hmac('sha256', $username.env('AWS_COGNITO_CLIENT_ID'), env('AWS_COGNITO_CLIENT_SECRET'), true)\n        );\n    }\n\n    \/**\n     * Register a new user in Cognito.\n     *\/\n    public function registerUser($name, $email, $password) {\n        try {\n            $username = explode('@', $email)&#91;0];\n\n            $response = $this -&gt; client -&gt; signUp(&#91;\n                'ClientId' =&gt; env('AWS_COGNITO_CLIENT_ID'),\n                'Username' =&gt; $username,\n                'Password' =&gt; $password,\n                'SecretHash' =&gt; $this -&gt; getSecretHash($username),\n                'UserAttributes' =&gt; &#91;\n                    &#91;'Name' =&gt; 'name', 'Value' =&gt; $name],\n                    &#91;'Name' =&gt; 'email', 'Value' =&gt; $email],\n                ],\n            ]);\n\n            \/\/ Check if Cognito confirms the user (Lambda trigger may be failing)\n            $userConfirmed = $response&#91;'UserConfirmed'] ?? false;\n\n            return response() -&gt; json(&#91;\n                'message' =&gt; 'User registered successfully.',\n                'userConfirmed' =&gt; $userConfirmed,\n                'cognitoResponse' =&gt; $response\n            ]);\n\n        } catch (\\Exception $e) {\n            return response() -&gt; json(&#91;\n                'error' =&gt; 'AWS Cognito Error: '.$e -&gt; getMessage()\n            ], 400);\n        }\n    }\n\n \/**\n     * Authenticate user with Cognito.\n     *\/\n    public function loginUser($email, $password) {\n        try {\n            $result = $this -&gt; client -&gt; initiateAuth(&#91;\n                'AuthFlow' =&gt; 'USER_PASSWORD_AUTH',\n                'ClientId' =&gt; env('AWS_COGNITO_CLIENT_ID'),\n                'AuthParameters' =&gt; &#91;\n                    'USERNAME' =&gt; $email,\n                    'PASSWORD' =&gt; $password,\n                    'SECRET_HASH' =&gt; $this -&gt; getSecretHash($email), \/\/ Important if client has a secret\n                ],\n            ]);\n\n            return &#91;\n                'message' =&gt; 'Login successful',\n                'token' =&gt; $result&#91;'AuthenticationResult']&#91;'AccessToken'],\n                'refresh_token' =&gt; $result&#91;'AuthenticationResult']&#91;'RefreshToken'],\n                'id_token' =&gt; $result&#91;'AuthenticationResult']&#91;'IdToken']\n            ];\n        } catch (Exception $e) {\n            return &#91;'error' =&gt; $e -&gt; getMessage()];\n        }\n    }\n\n    \/**\n     * Get authenticated user details.\n     *\/\n    public function getUser($accessToken) {\n        try {\n            $user = $this -&gt; client -&gt; getUser(&#91;\n                'AccessToken' =&gt; $accessToken,\n            ]);\n\n            return &#91;\n                'username' =&gt; $user&#91;'Username'],\n                'attributes' =&gt; $user&#91;'UserAttributes']\n            ];\n        } catch (Exception $e) {\n            return &#91;'error' =&gt; 'Invalid or expired token'];\n        }\n    }\n\n    \/**\n     * Refresh user token.\n     *\/\n    public function refreshToken($refreshToken) {\n        try {\n            $result = $this -&gt; client -&gt; initiateAuth(&#91;\n                'AuthFlow' =&gt; 'REFRESH_TOKEN_AUTH',\n                'ClientId' =&gt; env('AWS_COGNITO_CLIENT_ID'),\n                'AuthParameters' =&gt; &#91;\n                    'REFRESH_TOKEN' =&gt; $refreshToken,\n                    'SECRET_HASH' =&gt; $this -&gt; getSecretHash($refreshToken),\n                ],\n            ]);\n\n            return &#91;\n                'message' =&gt; 'Token refreshed successfully',\n                'token' =&gt; $result&#91;'AuthenticationResult']&#91;'AccessToken']\n            ];\n        } catch (Exception $e) {\n            return &#91;'error' =&gt; $e -&gt; getMessage()];\n        }\n    }\n\n    \/**\n     * Logout user from Cognito.\n     *\/\n    public function logoutUser($accessToken) {\n        try {\n            \/\/ Validate access token format\n            if (!$accessToken || !preg_match('\/^&#91;A-Za-z0-9-_=.]+$\/', $accessToken)) {\n                return &#91;'error' =&gt; 'Invalid or missing access token'];\n            }\n\n            \/\/ Perform global sign-out\n            $this -&gt; client -&gt; globalSignOut(&#91;\n                'AccessToken' =&gt; $accessToken,\n            ]);\n\n            return &#91;'message' =&gt; 'User logged out successfully'];\n        } catch (AwsException $e) {\n            return &#91;'error' =&gt; $e -&gt; getAwsErrorMessage()];\n        } catch (Exception $e) {\n            return &#91;'error' =&gt; $e -&gt; getMessage()];\n        }\n    }\n}<\/code><\/pre>\n\n\n\n<p>Step 17: Create routes:<br>Demo routes :  <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;? php\n\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Support\\Facades\\Route;\nuse App\\Http\\Controllers\\Cognito\\CognitoAuthController;\n\nRoute:: prefix('cognito') -&gt; group(function () {\n    Route:: post('\/register', &#91;CognitoAuthController:: class, 'register']);\n    Route:: post('\/login', &#91;CognitoAuthController:: class, 'login']);\n    Route:: get('\/user', &#91;CognitoAuthController:: class, 'user']);\n    Route:: post('\/logout', &#91;CognitoAuthController:: class, 'logout']);\n});<\/code><\/pre>\n\n\n\n<p>Step 18: Test routes on postman.<br><strong>Test 1: Register user<\/strong><br>Data field to be filled up in postman: name, email, password and password confirmation<br>Below is the image of the successful registration of user on the <strong>cognito user pool.<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"767\" height=\"470\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step18_Image1_Test1.webp\" alt=\"\" class=\"wp-image-2449\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step18_Image1_Test1.webp 767w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step18_Image1_Test1-300x184.webp 300w\" sizes=\"(max-width: 767px) 100vw, 767px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"832\" height=\"414\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step18_Image2_Test1.webp\" alt=\"\" class=\"wp-image-2450\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step18_Image2_Test1.webp 832w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step18_Image2_Test1-300x149.webp 300w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step18_Image2_Test1-768x382.webp 768w\" sizes=\"(max-width: 832px) 100vw, 832px\" \/><\/figure>\n\n\n\n<p><strong>Test 2: Login User<\/strong><br>Data field being filled in postman: email,password<br>On successful login the cognito will provide access token and refresh token as shown in the response.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"687\" height=\"488\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step18_Image3_Test2-1.webp\" alt=\"\" class=\"wp-image-2452\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step18_Image3_Test2-1.webp 687w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step18_Image3_Test2-1-300x213.webp 300w\" sizes=\"(max-width: 687px) 100vw, 687px\" \/><\/figure>\n\n\n\n<p><strong>Test 3: Get user Details<\/strong><br>Data fields being filled in postman: Authorization header-&gt; bearer token, that means access token which we got in the login response<\/p>\n\n\n\n<p>Successfully fetched details would look like below: <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"673\" height=\"474\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step18_Image4_Test3-1.jpg\" alt=\"\" class=\"wp-image-2456\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step18_Image4_Test3-1.jpg 673w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step18_Image4_Test3-1-300x211.jpg 300w\" sizes=\"(max-width: 673px) 100vw, 673px\" \/><\/figure>\n\n\n\n<p><strong>Test 4: Logout user<\/strong><br>Data fields being used in the postman: Authorization header-&gt; bearer token<br>Successfully logged out output would look like this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"741\" height=\"515\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step18_Image5_Test4-1.jpg\" alt=\"\" class=\"wp-image-2455\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step18_Image5_Test4-1.jpg 741w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Step18_Image5_Test4-1-300x209.jpg 300w\" sizes=\"(max-width: 741px) 100vw, 741px\" \/><\/figure>\n\n\n\n<p><strong>STAY TUNED FOR MORE USEFUL BLOGS!!<\/strong><\/p>\n\n\n\n<details class=\"wp-block-details is-layout-flow wp-block-details-is-layout-flow\"><summary>\ud83d\ude80 <strong>Transform Your Authentication Stack with 200OK Solutions<\/strong><br>Looking to implement secure, scalable, and modern login flows? At <strong>200OK Solutions<\/strong>, we specialize in AWS-integrated development, Laravel-based enterprise apps, and secure user management with AWS Cognito, SharePoint, and the Microsoft ecosystem.<br>Whether you&#8217;re building serverless solutions or automating workflows, our team of certified experts ensures seamless delivery.<br>\ud83d\udd10 <strong>Secure. Scalable. Serverless.<\/strong> Start your journey with a <a>free consultation<\/a>.<\/summary><div class=\"is-default-size wp-block-site-logo\"><a href=\"https:\/\/www.200oksolutions.com\/blog\/\" class=\"custom-logo-link light-mode-logo\" rel=\"home\"><img loading=\"lazy\" decoding=\"async\" width=\"484\" height=\"191\" src=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2026\/01\/cropped-200ok_logo.png\" class=\"custom-logo\" alt=\"Web Development, Software, and App Blog | 200OK Solutions\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2026\/01\/cropped-200ok_logo.png 484w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2026\/01\/cropped-200ok_logo-300x118.png 300w\" sizes=\"(max-width: 484px) 100vw, 484px\" \/><\/a><\/div><\/details>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\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p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>PRE-REQUISITES : Amazon Cognito User Pool has already been set up. HOW TO USE COGNITO WITH LARAVEL&hellip;<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[785],"tags":[1076,705,1080,1078,127,745,1077,1079,1081,1075],"class_list":["post-2405","post","type-post","status-publish","format-standard","hentry","category-aws","tag-aws-cognito","tag-aws-lambda","tag-cloud-authentication","tag-jwt-token","tag-laravel","tag-laravel-authentication","tag-laravel-with-aws","tag-secure-login","tag-serverless-login","tag-user-management"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>AWS COGNITO INTEGRATION WITH LARAVEL APPLICATION Web Development, Software, and App Blog | 200OK Solutions<\/title>\n<meta name=\"description\" content=\"Learn step-by-step how to integrate AWS Cognito with your Laravel application for secure authentication, auto-confirmation, JWT token handling, and seamless user management using AWS Lambda and IAM policies\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.200oksolutions.com\/blog\/aws-cognito-integration-with-laravel-application\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"AWS COGNITO INTEGRATION WITH LARAVEL APPLICATION Web Development, Software, and App Blog | 200OK Solutions\" \/>\n<meta property=\"og:description\" content=\"Learn step-by-step how to integrate AWS Cognito with your Laravel application for secure authentication, auto-confirmation, JWT token handling, and seamless user management using AWS Lambda and IAM policies\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.200oksolutions.com\/blog\/aws-cognito-integration-with-laravel-application\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Development, Software, and App Blog | 200OK Solutions\" \/>\n<meta property=\"article:published_time\" content=\"2025-07-01T07:19:21+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-12-04T07:44:03+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Picture1-1.webp\" \/>\n<meta name=\"author\" content=\"Piyush Solanki\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Piyush Solanki\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"AWS COGNITO INTEGRATION WITH LARAVEL APPLICATION Web Development, Software, and App Blog | 200OK Solutions","description":"Learn step-by-step how to integrate AWS Cognito with your Laravel application for secure authentication, auto-confirmation, JWT token handling, and seamless user management using AWS Lambda and IAM policies","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.200oksolutions.com\/blog\/aws-cognito-integration-with-laravel-application\/","og_locale":"en_US","og_type":"article","og_title":"AWS COGNITO INTEGRATION WITH LARAVEL APPLICATION Web Development, Software, and App Blog | 200OK Solutions","og_description":"Learn step-by-step how to integrate AWS Cognito with your Laravel application for secure authentication, auto-confirmation, JWT token handling, and seamless user management using AWS Lambda and IAM policies","og_url":"https:\/\/www.200oksolutions.com\/blog\/aws-cognito-integration-with-laravel-application\/","og_site_name":"Web Development, Software, and App Blog | 200OK Solutions","article_published_time":"2025-07-01T07:19:21+00:00","article_modified_time":"2025-12-04T07:44:03+00:00","og_image":[{"url":"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Picture1-1.webp","type":"","width":"","height":""}],"author":"Piyush Solanki","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Piyush Solanki","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.200oksolutions.com\/blog\/aws-cognito-integration-with-laravel-application\/#article","isPartOf":{"@id":"https:\/\/www.200oksolutions.com\/blog\/aws-cognito-integration-with-laravel-application\/"},"author":{"name":"Piyush Solanki","@id":"https:\/\/www.200oksolutions.com\/blog\/#\/schema\/person\/e07f6b8e3c9a90ce7b3b09427d26155e"},"headline":"AWS COGNITO INTEGRATION WITH LARAVEL APPLICATION","datePublished":"2025-07-01T07:19:21+00:00","dateModified":"2025-12-04T07:44:03+00:00","mainEntityOfPage":{"@id":"https:\/\/www.200oksolutions.com\/blog\/aws-cognito-integration-with-laravel-application\/"},"wordCount":787,"commentCount":0,"publisher":{"@id":"https:\/\/www.200oksolutions.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.200oksolutions.com\/blog\/aws-cognito-integration-with-laravel-application\/#primaryimage"},"thumbnailUrl":"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Picture1-1.webp","keywords":["AWS Cognito","AWS Lambda","Cloud Authentication","JWT Token","Laravel","Laravel Authentication","Laravel with AWS","Secure Login","Serverless Login","User Management"],"articleSection":["AWS"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.200oksolutions.com\/blog\/aws-cognito-integration-with-laravel-application\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.200oksolutions.com\/blog\/aws-cognito-integration-with-laravel-application\/","url":"https:\/\/www.200oksolutions.com\/blog\/aws-cognito-integration-with-laravel-application\/","name":"AWS COGNITO INTEGRATION WITH LARAVEL APPLICATION Web Development, Software, and App Blog | 200OK Solutions","isPartOf":{"@id":"https:\/\/www.200oksolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.200oksolutions.com\/blog\/aws-cognito-integration-with-laravel-application\/#primaryimage"},"image":{"@id":"https:\/\/www.200oksolutions.com\/blog\/aws-cognito-integration-with-laravel-application\/#primaryimage"},"thumbnailUrl":"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Picture1-1.webp","datePublished":"2025-07-01T07:19:21+00:00","dateModified":"2025-12-04T07:44:03+00:00","description":"Learn step-by-step how to integrate AWS Cognito with your Laravel application for secure authentication, auto-confirmation, JWT token handling, and seamless user management using AWS Lambda and IAM policies","breadcrumb":{"@id":"https:\/\/www.200oksolutions.com\/blog\/aws-cognito-integration-with-laravel-application\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.200oksolutions.com\/blog\/aws-cognito-integration-with-laravel-application\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.200oksolutions.com\/blog\/aws-cognito-integration-with-laravel-application\/#primaryimage","url":"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Picture1-1.webp","contentUrl":"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/06\/Picture1-1.webp"},{"@type":"BreadcrumbList","@id":"https:\/\/www.200oksolutions.com\/blog\/aws-cognito-integration-with-laravel-application\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.200oksolutions.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Home > Blog > AWS Cognito Integration > How to Use AWS Cognito with Laravel Application"}]},{"@type":"WebSite","@id":"https:\/\/www.200oksolutions.com\/blog\/#website","url":"https:\/\/www.200oksolutions.com\/blog\/","name":"Web Development, Software, and App Blog | 200OK Solutions","description":"","publisher":{"@id":"https:\/\/www.200oksolutions.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.200oksolutions.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.200oksolutions.com\/blog\/#organization","name":"Web Development Blog | Software Blog | App Blog","url":"https:\/\/www.200oksolutions.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.200oksolutions.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/09\/200ok_logo-CGzMrWDu.png","contentUrl":"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/09\/200ok_logo-CGzMrWDu.png","width":500,"height":191,"caption":"Web Development Blog | Software Blog | App Blog"},"image":{"@id":"https:\/\/www.200oksolutions.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.instagram.com\/200ok_solutions\/"]},{"@type":"Person","@id":"https:\/\/www.200oksolutions.com\/blog\/#\/schema\/person\/e07f6b8e3c9a90ce7b3b09427d26155e","name":"Piyush Solanki","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.200oksolutions.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/962a2b0b4db856e6851ec7d838597a0395adcaae9c0091d223de9942a4254461?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/962a2b0b4db856e6851ec7d838597a0395adcaae9c0091d223de9942a4254461?s=96&d=mm&r=g","caption":"Piyush Solanki"},"description":"Piyush is a seasoned PHP Tech Lead with 10+ years of experience architecting and delivering scalable web and mobile backend solutions for global brands and fast-growing SMEs. He specializes in PHP, MySQL, CodeIgniter, WordPress, and custom API development, helping businesses modernize legacy systems and launch secure, high-performance digital products. He collaborates closely with mobile teams building Android &amp; iOS apps , developing RESTful APIs, cloud integrations, and secure payment systems using platforms like Stripe, AWS S3, and OTP\/SMS gateways. His work extends across CMS customization, microservices-ready backend architectures, and smooth product deployments across Linux and cloud-based environments. Piyush also has a strong understanding of modern front-end technologies such as React and TypeScript, enabling him to contribute to full-stack development workflows and advanced admin panels. With a successful delivery track record in the UK market and experience building digital products for sectors like finance, hospitality, retail, consulting, and food services, Piyush is passionate about helping SMEs scale technology teams, improve operational efficiency, and accelerate innovation through backend excellence and digital tools.","url":"https:\/\/www.200oksolutions.com\/blog\/author\/piyush\/"}]}},"_links":{"self":[{"href":"https:\/\/www.200oksolutions.com\/blog\/wp-json\/wp\/v2\/posts\/2405","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.200oksolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.200oksolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.200oksolutions.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.200oksolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=2405"}],"version-history":[{"count":6,"href":"https:\/\/www.200oksolutions.com\/blog\/wp-json\/wp\/v2\/posts\/2405\/revisions"}],"predecessor-version":[{"id":2466,"href":"https:\/\/www.200oksolutions.com\/blog\/wp-json\/wp\/v2\/posts\/2405\/revisions\/2466"}],"wp:attachment":[{"href":"https:\/\/www.200oksolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=2405"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.200oksolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=2405"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.200oksolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=2405"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}