[英]lombucci/jwt It was not possible to parse your key, reason: error:0909006C:PEM routines:get_name:no start line
lombucci/jwt 4.1.5 PHP 8.0.10隆布奇/jwt 4.1.5 PHP 8.0.10
Getting the following issue when attempting to create a token尝试创建令牌时出现以下问题
It was not possible to parse your key, reason: error:0909006C:PEM routines:get_name:no start line
Here is a class that can be used to recreate this issue这是可用于重新创建此问题的 class
(token has been modified for the demo if that matters) (如果重要,令牌已针对演示进行了修改)
<?php
namespace Domain\MetaBase;
use Lcobucci\JWT\Configuration;
use Lcobucci\JWT\Signer\Key\InMemory;
use Lcobucci\JWT\Signer\Rsa\Sha256;
class Metabase
{
public function generateToken(): string
{
$metabaseSiteUrl = "https://potato.metabaseapp.com";
$metabaseSecretKey = "1690e6bf587bc61b5cdd3897c143291caa48779cc7abef104abf952fec6e8d4a";
$now = new \DateTimeImmutable();
$config = Configuration::forSymmetricSigner(new Sha256(), InMemory::plainText($metabaseSecretKey));
$token = $config->builder()
->issuedBy($metabaseSiteUrl)
->withHeader('iss', $metabaseSiteUrl)
->permittedFor($metabaseSiteUrl)
->issuedAt($now)
->canOnlyBeUsedAfter($now->modify('+1 minute'))
->expiresAt($now->modify('+1 hour'))
->withClaim('resource', ['question' => 15])
//METABASE resource (question, card, dashboard)
->withClaim('params', ['cod_usuario' => 1001])
//METABASE params variables metabase
->getToken($config->signer(), $config->signingKey());
return $metabaseSiteUrl . "/embed/question/" . $token->toString() . "#bordered=true&titled=true";
}
}
The issue I was having was that I was using我遇到的问题是我正在使用
Lcobucci\JWT\Signer\Rsa\Sha256;
when I should have been using当我应该使用
use Lcobucci\JWT\Signer\Hmac\Sha256;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.