Skip to content

Commit

Permalink
Merge pull request #52 from lahirumenik/main
Browse files Browse the repository at this point in the history
tested lambda auth sigin to fetch access token
  • Loading branch information
lahirumenik authored Jan 6, 2024
2 parents 46c972d + 6fa413f commit c29721e
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions backend/serverless/testing/siginauth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const AWS = require('aws-sdk');
const cognito = new AWS.CognitoIdentityServiceProvider();

exports.handler = async (event, context, callback) => {
// Process authentication request
// Use Cognito API to authenticate the user
const cognitoResponse = await cognito.initiateAuth({
AuthFlow: 'USER_PASSWORD_AUTH',
AuthParameters: {
Username: event.username,
Password: event.password,
},
ClientId: '1q2aum3ptjv1hpb4u3spldal8r',
}).promise();

// Generate access token
const accessToken = cognitoResponse.AuthenticationResult.AccessToken;

// Include the access token in the response
return {
statusCode: 200,
body: JSON.stringify({ accessToken }),
};
}

0 comments on commit c29721e

Please sign in to comment.