【问题标题】:Yammer authentication issuesYammer 身份验证问题
【发布时间】:2017-10-03 09:47:19
【问题描述】:

我正在 Outsystems 上创建一个使用 Yammer API 的应用。问题是 Yammer 身份验证导致了一些问题。在页面的“OnReady”属性中,我添加了以下代码:

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);
    }
  });
}
}
);

它成功返回了一个令牌,我可以使用 console.log() 对其进行验证。此外,我添加了一个登录按钮,该按钮在其 OnClick 属性中具有相同的代码。

问题是,当我尝试从 OnReady 执行 Get Messages API 调用(端点:https://www.yammer.com/api/v1/messages.json)时,它给了我 401 Unauthorized access 错误。但是,当我另外使用 OnReady 并单击 Login 按钮时,API 调用成功。我不明白为什么,因为两个调用收到的令牌完全相同,但是用户登录两次后它就起作用了?有什么办法可以解决吗?

附:我试过使用另一个端点(https://api.yammer.com/api/v1/messages.json)。我遇到了同样的问题。

【问题讨论】:

    标签: json api yammer outsystems


    【解决方案1】:

    尝试在回调函数中添加$resolve()。这样代码将等到它完成后再继续你的下一个jav

    【讨论】:

      猜你喜欢
      • 2015-05-28
      • 1970-01-01
      • 2016-09-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多