【问题标题】:OpenTok API AuthenticationOpenTok API 身份验证
【发布时间】:2017-08-18 09:23:18
【问题描述】:

我正在尝试在我的 Angular 应用程序中调用 OpenTok API。我正在使用以下代码

 $http({
    method: 'POST',
    url: 'https://api.opentok.com/v2/project/{{apiKey}}/broadcast',
    data: data,
    headers: {
      'Authorization':'X-OPENTOK-AUTH',
      'Content-Type': 'application/json'
    },
    token: json_web_token
  })

我有一个有效的 json_web_token 我正在传递。但是,每当我尝试进行此调用时,我都会得到。

{"code":-1,"message":"No suitable authentication found"}

我很难弄清楚如何设置自定义 X-OPENTOK-AUTH 标头。谁能告诉我我的代码有什么问题,或者有没有人有对 OpenTok 进行 $http 调用的示例?

【问题讨论】:

    标签: opentok tokbox


    【解决方案1】:

    我弄错了 JSON Web 令牌。必须将其移至后端并在那里完成所有操作。

    这有帮助 https://tokbox.com/blog/author/madhav/

    【讨论】:

      【解决方案2】:

      以迈克的回答为基础,问题是这样的:

      'Authorization':'X-OPENTOK-AUTH',
      

      不正确。 X-OPENTOK-AUTH 应该是标头名称,而不是标头值。 Authorization 标头名称被忽略。它应该类似于:

      'X-OPENTOK-AUTH': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiIxMjMiLCJpc3QiOiJwcm9qZWN0IiwiaWF0IjoxNTAyMzMxNDk3LCJleHAiOjE1MDIzMzE3OTd9.WJ1yJkD6IgXofj85Wyjdl80QEumLVBHIgtj-9vAhOZU'
      

      请参阅https://tokbox.com/developer/rest/#authentication 以获取 API 参考或https://tokbox.com/blog/jwt-the-new-authentication-scheme-for-opentok-rest-endpoints/ 以获取有关该主题的博客文章。

      【讨论】:

        猜你喜欢
        • 2017-11-29
        • 2016-04-12
        • 2016-04-24
        • 1970-01-01
        • 2011-11-28
        • 2011-03-29
        • 2013-09-11
        • 2018-08-07
        • 2015-05-15
        相关资源
        最近更新 更多