Basic Auth REST

anuragG
New Contributor III
New Contributor III
Team,
Below Connection JSON is not working-
{
  "authentications": {
    "acctAuth": {
      "authType": "Basic",
      "url": "<URL>",
      "httpMethod": "POST",
      "httpParams": {},
      "httpHeaders": {},
      "httpContentType": "text/html",
      "properties": {
        "userName":"<username>",
        "password":"<pass>"
      },
      "expiryError": "ExpiredAuthenticationToken",
      "authError": [
        "InvalidAuthenticationToken",
        "AuthenticationFailed"
      ],
      "timeOutError": "Read timed out",
      "errorPath": "error.code",
      "maxRefreshTryCount": 5,
      "tokenResponsePath": "access_token",
      "tokenType": "Basic",
      "accessToken": "Basic WFJYX1dQUl3c1XndkRjkjeGg3",
      "apiRateLimitConfig": {"retryAfterCalls": 100,"retryWaitSeconds": 60}
    }
  }
}
 
 
anuragG_2-1690366089090.png

This is the error I see in the logs. What am I doing wrong?

 

FYI API is working through postman with Basic auth.

 

8 REPLIES 8

pmahalle
Valued Contributor II
Valued Contributor II

Hi @anuragG ,

Check your token response path is correct or not.

   "tokenResponsePath": "access_token",

Share authentication response you are getting in postman.


Regards,

Pandharinath Mahalle(Paddy)
If this reply answered your question, please Accept it As Solution to help others who may have a similar problem.

anuragG
New Contributor III
New Contributor III

@pmahalle The API does not have response when authenticated -

anuragG_4-1690371943356.png

 

anuragG_3-1690371905506.png

 

And API is working from postman, for eg, in 2nd picture, you can see attribute XGUID - ADWPM2 with Status 200.

Same is getting populated in the target table-

anuragG_2-1690371815544.png

 

naveenss
All-Star
All-Star

@anuragG  can you try with the below JSON?

{
    "authentications": {
        "acctAuth": {
            "authType": "Basic",
            "url": "<URL>",
            "httpMethod": "POST",
            "httpParams": {},
            "httpHeaders": {},
            "httpContentType": "text/html",
            "properties": {
                "userName": "<username>",
                "password": "<pass>"
            },
            "expiryError": "ExpiredAuthenticationToken",
            "authError": [
                "InvalidAuthenticationToken",
                "AuthenticationFailed"
            ],
            "timeOutError": "Read timed out",
            "errorPath": "error.code",
            "maxRefreshTryCount": 5,
            "tokenResponsePath": "access_token",

            "tokenType": "Basic",
            "accessToken": "Basic WFJYX1dQUl3c1XndkRjkjeGg3",
            "retryFailureStatusCode": [
                401
            ],
            "apiRateLimitConfig": {
                "retryAfterCalls": 100,
                "retryWaitSeconds": 60
            }
        }
    }
}
Regards,
Naveen Sakleshpur
If this reply answered your question, please click the Accept As Solution button to help future users who may have a similar problem.

anuragG
New Contributor III
New Contributor III

hi @naveenss Issue still persists, still getting the below error-

2023-07-26 12:31:02,019 [quartzScheduler_Worker-5] ERROR rest.RestProvisioningService - Access Token is null..

@anuragG  are you getting this in the createAccount JSON? can you please share the JSON you're using. Not the connection JSON btw.

 

Regards,
Naveen Sakleshpur
If this reply answered your question, please click the Accept As Solution button to help future users who may have a similar problem.

anuragG
New Contributor III
New Contributor III

@naveenss Yes, PFB createacc JSON below-

{
"accountIdPath": "accountName",
"call": [{
"name": "call1",
"connection": "userAuth",
"url": "<url>",
"httpMethod": "POST",
"httpParams": "{ \"XGUID\": \"${user.customproperty21}\", \"S3_USER_ID\": \"${user.username}\", \"PERSON_STATUS\": \"${com.adw.PersonStatus.Personstatus(user.customproperty49)}\", \"LAST_NAME\": \"${user.lastname}\", \"FIRST_NAME\": \"${user.firstname}\", \"EMAIL\": \"${user.email}\", \"S3_EMPLOYEE_TYPE\": \"${user.employeeType}\", \"COUNTRY_CODE\": \"${com.adw.CountryCodeConverter_2.convertToThreeLetterCode(user.customproperty3)}\", \"COMPANY\": \"${user.companyname}\", \"STREET\": \"${user.street}\", \"STATE\": \"${user.state}\", \"POSTAL_CODE\": \"${user.region}\", \"MANAGER_NAME\": \"${com.adw.ManagerData.Mdp(user.owner.toString())}\", \"MANAGER_XGUID\": \"${com.adw.ManagerData.xguid(user.owner.toString())}\", \"TIME_STAMP\": \"${com.adw.SystemDateCalculator.getFormattedSystemDate()}\", \"RECORD_TYPE\": \"NEW\", \"SOR\": \"${user.customproperty15}\", \"FEED_PK\": \"${user.customproperty40}\", \"PERSONNEL_NUMBER\": \"${user.employeeid}\" }",
"httpHeaders": {
"Authorization": "${access_token}"
},
"httpContentType": "application/x-www-form-urlencoded",
"successResponses": {
"statusCode": [200]
}
}]
}

Hi @anuragG  I see the connectionName in connnection JSON is acctAuth. but in create acc json, it is userAuth. Please change it to "acctAuth" like below and retry again. 

"connection": "acctAuth"

 

Regards,
Naveen Sakleshpur
If this reply answered your question, please click the Accept As Solution button to help future users who may have a similar problem.

pmahalle
Valued Contributor II
Valued Contributor II

@anuragG Connection name is wrong in createaccount json. Correct it as per the connection json.

"connection": "acctAuth"


Regards,

Pandharinath Mahalle(Paddy)
If this reply answered your question, please Accept it As Solution to help others who may have a similar problem.