http://m.wtbis.cn/plugin/10
JWT
怎么實(shí)現(xiàn)傳遞token獲取id等信息
不通過(guò)header頭部傳遞
和使用JwtToken::getCurrentId()
比如
$xx = wewrewrwer23(這里是token)
調(diào)用某個(gè)方法
$xxx = XXXXXX($xx)
echo $xxx;
讀一下插件的源碼就知道了啊,把方法復(fù)制出來(lái),自己寫一個(gè)方法,就可以用了。
下面是從源碼中復(fù)制出來(lái)的方法。
private static function verifyToken(string $token, int $tokenType): array
{
$config = self::_getConfig();
$publicKey = self::ACCESS_TOKEN == $tokenType ? self::getPublicKey($config['algorithms']) : self::getPublicKey($config['algorithms'], self::REFRESH_TOKEN);
JWT::$leeway = $config['leeway'];
$decoded = JWT::decode($token, new Key($publicKey, $config['algorithms']));
$decodeToken = json_decode(json_encode($decoded), true);
if ($config['is_single_device'] && self::ACCESS_TOKEN == $tokenType) {
RedisHandler::verifyToken($config['cache_token_pre'], (string) $decodeToken['extend']['id'], $token);
}
return $decodeToken;
}