Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Action Step. Get Connection Info step

Alex153
Tera Contributor

Hi,

I want to use connection alias in my script (see screenshot). But I do not know if I understand the logic correctly.
First I add "Get Connection Info step" as a first step that gives me var "Credential value" (see screenshot). Then I insert "Credential value" to my script (var encryptedCredential = inputs.credentialvalue), decrypt it (

decryptedCredential = encryptedCredential.getDecryptedValue();) and create a REST GET request:

 

        var request = new sn_ws.RESTMessageV2();
        request.setHttpMethod('GET');
        request.setEndpoint(url);
        request.setRequestHeader('Authorization', 'Bearer ' + decryptedCredential);

 

and get the error

 

Response Body: {
"error": {
"code": 401,
"message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"errors": [
{
"message": "Invalid Credentials",
"domain": "global",
"reason": "authError",
"location": "Authorization",
"locationType": "header"
}
],
"status": "UNAUTHENTICATED",
"details": [
{
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "ACCESS_TOKEN_TYPE_UNSUPPORTED",
"metadata": {
"method": "google.cloud.bigquery.v2.TableDataService.List",
"service": "bigquery.googleapis.com"
}
}
]
}
}

 

What am I doing wrong? Is the logic correct?

0 REPLIES 0