04/12/2022 01:22 PM
Hi,
I have rest connector endpoint serving as the authoritative source for employees and contractors. The REST endpoint uses a username, password, and clientId passed in the header of a POST request in order to return an access token. The token returned is a Bearer token and is passed into the Authentication attribute of the ImportUserJSON call header. I can get the user import to run successfully when I hardcode an access token retrieved using Postman, but my connectionJSON fails to return a valid access token dynamically.
The full ConnectionJSON is as follows:
{
"authentications": {
"MyConnection": {
"authType": "oauth2",
"url": "<url endpoint matching postman call>",
"httpMethod": "POST",
"httpParams": {
"AuthParameters": {
"USERNAME": "<username>",
"PASSWORD": "<password>"
},
"AuthFlow": "<auth flow>,
"ClientId": "<client id>"
},
"httpHeaders": {
"Content-Type": "application/x-amz-json-1.1",
"X-Amz-Target": "AWSCognitoIdentityProviderService.InitiateAuth",
"Accept": "application/json"
},
"httpContentType": "application/json",
"authError": [
"Incorrect username or password."
],
"retryFailureStatusCode": [
401
],
"errorPath": "errors[0].message",
"expiryError": "Token has expired.",
"maxRefreshTryCount": 5,
"tokenResponsePath": "AuthenticationResult.AccessToken",
"tokenType": "Bearer",
"accessToken": "Bearer xyz"
}
}
}
Token endpoint response format from Postman:
{
"AuthenticationResult": {
"AccessToken": "token...",
"ExpiresIn": 3600
},
"ChallengeParameters": {}
}
Questions:
Solved! Go to Solution.
04/12/2022 03:07 PM
Answers:
04/12/2022 03:07 PM
Hello Brian,
Could you post your final JSON here so that the community can use it as a reference in the future ?
Regards,
Avinash Chhetri
04/12/2022 03:07 PM
My JSON is below. Is it required to not specify the accessToken parameter? This appears to go against REST connector documentation, but it works for me.
{
"authentications": {
"MyConnection": {
"authType": "oauth2",
"url": "<url>",
"httpMethod": "POST",
"httpParams": {
"AuthParameters": {
"USERNAME": "<username>,
"PASSWORD": "<password>"
},
"AuthFlow": "USER_PASSWORD_AUTH",
"ClientId": "<client id>"
},
"httpHeaders": {
"Content-Type": "application/x-amz-json-1.1",
"X-Amz-Target": "AWSCognitoIdentityProviderService.InitiateAuth",
"Accept": "application/json"
},
"httpContentType": "application/json",
"authError": [
"Incorrect username or password."
],
"retryFailureStatusCode": [
401
],
"errorPath": "errors[0].message",
"expiryError": "Token has expired.",
"maxRefreshTryCount": 5,
"tokenResponsePath": "AuthenticationResult.AccessToken"
}
}
}