Re: How to execute multiple CF REST methods with an unique authentication


CF Runtime
 

A token should be valid for any number of requests until the expiration
time is reached.

In your code example, is the "result" passed to your second call to
"getApps" the result from the login attempt, or the result from the first
"getApps" call? You might try console.log(results) before that second
getApps call.

Joseph
OSS Release Integration Team

On Mon, Sep 7, 2015 at 3:05 AM, Juan Antonio BreƱa Moral <
bren(a)juanantonio.info> wrote:

Currently,

If I execute 2 operations with the same token, I receive the following
message:

it.only("Using Login to execute 2 REST operations", function () {
this.timeout(2500);

CloudFoundry.setEndPoint(endPoint);

var token_endpoint = null;
var refresh_token = null;
return CloudFoundry.getInfo().then(function (result) {
token_endpoint = result.token_endpoint;
return CloudFoundry.login(token_endpoint, username, password);
}).then(function (result) {
return CloudFoundryApps.getApps(result.token_type,
result.access_token);
}).then(function (result) {
return CloudFoundryApps.getApps(result.token_type,
result.access_token);
}).then(function (result) {
console.log(result);
expect(true).to.equal(true);
});
});

Tests Response:

1) Cloud Foundry Using Login to execute 2 REST operations:
Error: the string "{\n \"code\": 10002,\n \"description\":
\"Authenticati
on error\",\n \"error_code\": \"CF-NotAuthenticated\"\n}\n" was thrown,
throw a
n Error :)

Join {cf-dev@lists.cloudfoundry.org to automatically receive all group messages.