3 weeks ago
I have two services A and B in different CAP apps that share the same XSUAA. I'd like service A to call the remote service B in a background job. This results in a 401 error as there is no auth token.
cds.spawn({}, async () => {
const serviceB = await cds.connect.to("B");
await serviceB.send("foo", {}); // 401 error
});
Service B does have a destination configured
"requires": {
"B": {
"kind": "odata",
"model": "./srv/external/B",
"[production]": {
"credentials": {
"path": "/api/",
"destination": "b-api",
"forwardAuthToken": true
}
},
}
Remote calls to service B work as intended when initiated inside request handling, as there is an auth token to be forwarded.
serviceA.on("bar", async () => {
const serviceB = await cds.connect.to("B");
await serviceB.send("foo", {}); // works
});
Is there a way for CAP to handle this automatically or do I have to fetch the token manually and set it in the header?
User | Count |
---|---|
67 | |
11 | |
10 | |
10 | |
9 | |
9 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.