OKTA SSO验证显示无效的URL

时间:2019-08-06 13:14:26

标签: php jwt okta-api

当我尝试使用SpomkyLabsJose库以及客户端提供的凭据来验证JWT令牌时,它显示 “无效的网址。 200“ 我不知道为什么显示200。 此外,令牌是使用OpenID Connect创建的。该代码粘贴在下面。

我尝试用PHP JWT库对其进行解码,但发现没有密钥就无法完成。但是在我们的情况下,客户端不会提供密钥

<?php
$jwt = $_REQUEST['id_token'];

$jwtVerifier = (new \Okta\JwtVerifier\JwtVerifierBuilder())
    ->setDiscovery(new \Okta\JwtVerifier\Discovery\Oauth) // This is not needed if using oauth.  The other option is OIDC
    ->setAdaptor(new \Okta\JwtVerifier\Adaptors\SpomkyLabsJose)
    ->setAudience('api://default')
    ->setClientId('{clientId}')
    ->setIssuer('https://{yourOktaDomain}.com/oauth2/default')
    ->build();

$jwt = $jwtVerifier->verify($jwt);

dump($jwt); //Returns instance of \Okta\JwtVerifier\JWT

dump($jwt->toJson()); // Returns Claims as JSON Object

dump($jwt->getClaims()); // Returns Claims as they come from the JWT Package used

dump($jwt->getIssuedAt()); // returns Carbon instance of issued at time
dump($jwt->getIssuedAt(false)); // returns timestamp of issued at time

dump($jwt->getExpirationTime()); //returns Carbon instance of Expiration Time
dump($jwt->getExpirationTime(false)); //returns timestamp of Expiration Time

0 个答案:

没有答案