我得到403" NotAllowedException"使用mestream和getstream stream.js添加活动时

时间:2018-02-09 14:06:04

标签: getstream-io

当我尝试向我的客户端添加活动时,我不断收到以下回复:

module.exports {offset: 145, readable: true, _events: {…}, statusCode: 403, headers: {…}, …}
body:
code:17
detail:"You do not have permission to perform this action."
duration:"0.00ms"
exception:"NotAllowedException"
status_code:403
__proto__:Object
caseless:Caseless {dict: {…}}
headers:{content-type: "text/plain; charset=utf-8"}
offset:145
readable:true
request:Request {_events: {…}, _maxListeners: undefined, body: "{"actor":"JamesAgwa","message":"This is a sample p…"verb":"post","object":"user:1","foreign_id":"1"}", signature: "user1 UgGaoBfBoazmPhfxkln_O3NDC1I", headers: {…}, …}
statusCode:403
toJSON:ƒ responseToJSON()
_events:{close: Array(3), ready: ƒ, error: Array(2), end: Array(3), data: ƒ}
__proto__:Stream

我一直得到:"您无权执行此操作。"

这是客户端代码:

// client side instantiation of the stream service
import Cookies from 'js-cookie';
import stream from 'getstream';

const client = stream.connect('9uw2mdcxjhzh', null, '29400');
const ActiveUser = client.feed(
 'user',
 `${Cookies.getJSON('loggedInUser') ? 
 Cookies.getJSON('loggedInUser').profile.name.split(' ').join(''): 1 }`,
 'UgGaoBfBoazmPhfxkln_O3NDC1I',
);

export default ActiveUser;

然后导入上述代码并按原样使用:

ActiveUser
  .addActivity({
    actor: this.state.currentUser.profile.name.split(' ').join(''),
    message,
    verb: 'post',
    object: 'user:1',
    foreign_id: '1',
  })
  .then((data) => {
    evt.target.reset();
    console.log(data);
  })
  .catch((err) => {
    console.log(err.response);
    evt.target.reset();
  });

1 个答案:

答案 0 :(得分:0)

认为您应该定期生成新的客户端订阅源令牌。我不确定这些令牌到期的频率。 (假设,使用"尝试API"页面可能的相同令牌,但我不确定。最佳做法是定期生成新令牌。 )

您可以在此处找到有关如何生成客户端令牌的文档:https://getstream.io/docs/#realtime