Using Yammer API in Outsystems Mobile App

Using Yammer API in Outsystems Mobile App

  

I'm creating an app on Outsystems, which uses the Yammer API. The issue is the Yammer authentication is causing some problems. In the "OnReady" property of the page, I've added the following code:

yam.getLoginStatus(
function(response) {
if (response.authResponse) {
  console.log("logged in");
  $parameters.Token = response.access_token.token;
  console.dir(response); //print user information to the console
}
else {
  yam.platform.login(function (response) { //prompt user to login and authorize your app, as necessary
    if (response.authResponse) {
      console.dir(response); //print user information to the console
      console.dir(response.access_token.token);
      $parameters.Token = response.access_token.token;
      console.dir($parameters.Token);
    }
  });
}
}
);

It successfully returns a token, which I am able to verify using console.log(). Additionally, I've added a Login button which has the same code in its OnClick property.

The issue is, when I try to perform the Get Messages API call (Endpoint: https://www.yammer.com/api/v1/messages.json) from OnReady, it gives me the 401 Unauthorized access error. But, when I additionally use the OnReady, and also click the Login button, the API call is successful. I don't understand why, because the token received by both calls are the exact same, but it works after the user logs through the OnReady, and cliking the button, even though they give the same response? Any way to rectify this?

P.S. I've tried using the other endpoint (https://api.yammer.com/api/v1/messages.json). I'm getting the same problem.

Additionally, I get the following error in the console when the page loads:

XMLHttpRequest cannot load https://www.yammer.com/platform/login_status.json?client_id=wZuyoeLNhd1SR6pF5faXUg. The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin 'https://saurav-sircar.outsystemscloud.com' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.