简体   繁体   English

Nexmo 错误 Builder#withClaim() 用于未注册的声明,请查看有关如何设置声明“sub”的文档

[英]Nexmo error Builder#withClaim() is meant to be used for non-registered claims, check the documentation on how to set claim “sub”

I can't generate jwt from provided claims.我无法从提供的声明中生成 jwt。 this my code:这是我的代码:

$keypair = new \Vonage\Client\Credentials\Keypair(file_get_contents(storage_path('voip/vonage/private.key')), env('NEXMO_APPLICATION_ID'));
    $client = new \Vonage\Client($keypair);

    $claims = [
      'exp' => strtotime(date('Y-m-d', strtotime('+24 Hours'))),
      'sub' => 'apg-cs',
      'acl' => [
        'paths' => [
          '/*/users/**' => (object) [],
          '/*/conversations/**' => (object) [],
          '/*/sessions/**' => (object) [],
          '/*/devices/**' => (object) [],
          '/*/image/**' => (object) [],
          '/*/media/**' => (object) [],
          '/*/applications/**' => (object) [],
          '/*/push/**' => (object) [],
          '/*/knocking/**' => (object) [],
          '/*/legs/**' => (object) [],
        ]
      ],
    ];
    $token = $client->generateJwt($claims);
    return $token->toString();

the error:错误:

Builder#withClaim() is meant to be used for non-registered claims, check the documentation on how to set claim "sub"

when i remove the "sub" from claims, vonage will thrown error:当我从声明中删除“子”时,vonage 将抛出错误:

user:error:invalid-user

This is a bug.这是一个错误。 The JWT library we use changed quite a few things between v3 and v4, and this looks like one of them.我们使用的 JWT 库在 v3 和 v4 之间改变了很多东西,这看起来像是其中之一。 Since the Conversation API is still considered Beta this compatibility wasn't checked, but I'll make sure it works.由于对话 API 仍被视为测试版,因此未检查此兼容性,但我会确保它有效。

I've opened a github issue at https://github.com/Vonage/vonage-php-sdk-core/issues/276c and will get this fixed ASAP.我已经在https://github.com/Vonage/vonage-php-sdk-core/issues/276c打开了 github 问题,并将尽快修复此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 允许非注册用户上传文件 - Allow file uploads for non-registered users 如何计算未注册用户按下“搜索”,然后将其保存在MySQL数据库中并为每个用户限制该次数的次数? - How to count the number of times a non-registered User presses “Search”, then save it in MySQL database and limit that number for every user? 向队列中的非注册用户(电子邮件列表)发送邮件 - send mail to non-registered user (email list) in a queue 关键字“finally”是如何在 PHP 中使用的? - How is the keyword 'finally' meant to be used in PHP? 如何在 Nexmo 代码中设置我的 php 变量 - How can I set my php variables in Nexmo code “未找到类‘Nexmo\\Laravel\\Facades\\Nexmo’”错误 - "Class 'Nexmo\\Laravel\\Facades\\Nexmo' not found" Error 如何获得由臭名昭著的“试图获取非对象的属性”错误消息表示的确切属性? - How to get exact property meant by infamous “trying to get property of non-object” error message? Laravel - Nexmo“请提供 Nexmo API 凭据”错误 - Laravel - Nexmo "Please provide Nexmo API credentials" Error 如何检查电子邮件是否已经注册? - How to check if email is already registered? 如何检查电子邮件或用户名是否已注册 - How to check if email or username are registered
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM