Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Endpoint:
- https://cognito-idp.ap-southeast-2.amazonaws.com/
- # Curl Command:
- curl --location 'https://cognito-idp.ap-southeast-2.amazonaws.com/' \
- --header 'Content-Type: application/x-amz-json-1.1' \
- --header 'x-amz-target: AWSCognitoIdentityProviderService.InitiateAuth' \
- --data-raw '{
- "AuthFlow": "USER_PASSWORD_AUTH",
- "ClientId": "{{clientId}}",
- "AuthParameters": {
- "USERNAME": "{{email}}",
- "PASSWORD":"{{password}}",
- "SECRET_HASH": "{{secretHash}}"
- }
- }'
- # Pre-request Script:
- const clientSecret = pm.environment.get("clientSecret")
- const clientId = pm.environment.get("clientId")
- const email = pm.environment.get("email")
- pm.sendRequest("https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/crypto-js.min.js", (error, response) => {
- if (error || response.code !== 200) {
- pm.expect.fail('Could not load external library');
- }
- eval(response.text());
- const CryptoJS = require('crypto-js');
- const digest = CryptoJS.enc.Base64.stringify(CryptoJS.HmacSHA256(email + clientId, clientSecret));
- pm.environment.set("secretHash",digest.toString())
- });
- # Test:
- const responseJson = pm.response.json();
- console.log("response",responseJson)
- pm.environment.set("token",responseJson['AuthenticationResult']['AccessToken'])
Add Comment
Please, Sign In to add comment