We're reclaiming inactive PDIs to keep them available foractive builders.Learn what's changing, who's affected, and how to protect your work. Read More
I'm struggling to understand what is wrong with `ConnectionInforProvider`.
I'm using it in a Script Include that is trying to get a Bearer token from an API endpoint.
function getAuthorizationToken(aliasId) {
var token = undefined;
var provider = new sn_cc.ConnectionInfoProvider();
var connectionInfo = null;
try {
connectionInfo = provider.getConnectionInfoByDomain(aliasId, 'global');
} catch(e) {
gs.error(JSON.stringify(e));
}
if (connectionInfo == null) {
try {
connectionInfo = provider.getConnectionInfoByDomain(aliasId, 'e4872febdbc29010ece1a0f2ca961940');
} catch(e) {
gs.error(JSON.stringify(e));
}
}
if (connectionInfo == null) {
try {
connectionInfo = provider.getConnectionInfo(aliasId);
} catch(e) {
gs.error(JSON.stringify(e));
}
}
var username = connectionInfo.getCredentialAttribute('user_name');
// REST OF THE CODE IS OMITTED DUE TO OUT OF SCOPE
}
This script is used inside a Data Source, which is also used in a Scheduled Data Import.
If opening the Data Source, I click on `Test Load 20 Records`, it works fine - credentials are retrieved and the token is generated correctly.
Instead, if opening the Scheduled Data Import, I click on `Execute Now`, it won't work, and, checking the logs the following exception is thrown (note: the line corresponds to `var username = connectionInfo.getCredentialAttribute('user_name')`).