Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
xssec.createSecurityContext(accessToken, this._xsuaaService.credentials, function (err, securityContext) {
if (err) {
debug(`Token exchange error: ${err}`);
return reject(err);
}
debug('Security context created successfully');
let grantType = xssec.constants.TYPE_USER_TOKEN;
if (securityContext.getGrantType() === 'client_credentials') {
grantType = xssec.constants.TYPE_CLIENT_CREDENTIALS_TOKEN;
}
securityContext.requestToken(this._credentials, grantType, {}, function (err, newToken) {
if (err) {
debug(`Token exchange error: ${err}`);
return reject(err);
}
debug('Token successfully exchanged');
return resolve(newToken);
});
}.bind(this));
}.bind(this));
xssec.createSecurityContext(accessToken, this._xsuaaService.credentials, function (err, securityContext) {
if (err) {
debug(`Token exchange error: ${err}`);
return reject(err);
}
debug('Security context created successfully');
let grantType = xssec.constants.TYPE_USER_TOKEN;
if (securityContext.getGrantType() === 'client_credentials') {
grantType = xssec.constants.TYPE_CLIENT_CREDENTIALS_TOKEN;
}
securityContext.requestToken(this._credentials, grantType, {}, function (err, newToken) {
if (err) {
debug(`Token exchange error: ${err}`);
return reject(err);
}
debug('Token successfully exchanged');
return resolve(newToken);
});
}.bind(this));
}.bind(this));