因为目前处理的 wordpress 网站使用了,使用

  1. qtranslate-x 多语言插件
  2. JWT Authentication for WP REST API 插件 rest api 登录

调用wp-json/jwt-auth/v1/token 可以登录成功,但通过 jwt.io 网站中的 Debugger,发现 token的 末尾多了 语言后缀 ,如图:

因为 get_bloginfo('url') 方法获取到的是没有 语言后缀或 默认语言的 wordpress 站点地址(URL)

只能修改 jwt-authentication-for-wp-rest-api/public/class-jwt-auth-public.phpvalidate_token方法

$token = JWT::decode($token, $secret_key, array('HS256'));
/** The Token is decoded now validate the iss */
if ($token->iss != get_bloginfo('url')) {
/** The iss do not match, return error */
return new WP_Error(
'jwt_auth_bad_iss',
__('The iss do not match with this server', 'wp-api-jwt-auth'),
array(
'status' => 403,
)
);
}

修改为

$token = JWT::decode($token, $secret_key, array('HS256'));
//get_bloginfo('url')
$iss_url = defined('JWT_AUTH_ISS_URL') ? JWT_AUTH_ISS_URL : get_bloginfo('url');
/** The Token is decoded now validate the iss */
if ($token->iss != $iss_url) {
/** The iss do not match, return error */
return new WP_Error(
'jwt_auth_bad_iss',
__('The iss do not match with this server', 'wp-api-jwt-auth'),
array(
'status' => 403,
)
);
}

最后在站点的 wp-config.php 中,添加一个

// this value equal `WordPress Address (URL)`
define('JWT_AUTH_ISS_URL','http://192.168.1.184/test');

最新文章

  1. PHP之图片上传类(加了缩略图)
  2. Unable to add window -- token null is not for an application
  3. IOS开发之——Masonry 只支持OC,暂不支持swift
  4. MySQL (ZIP Archive) 下载及安装及卸载
  5. Error NO.2013 Lost connection to Mysql server during query
  6. Angular 1.2.27在IE7下的兼容问题
  7. Log4net Level
  8. Tcl与Design Compiler (十二)——综合后处理
  9. iOS Push详述,了解一下?
  10. JavaScript单线程的疑问与解答
  11. 分布式逻辑管理平台XXL-GLUE
  12. 好程序员web前端分享javascript关联数组用法总结
  13. Java Socket、计算机网络
  14. MySQL与MongoDB
  15. C#实现多个PDF合并及去除文字水印功能
  16. 解决SpringBoot的@Autowired无法注入问题
  17. CentOS5.5上安装Python2.7及ez_setup和pip包
  18. Spring Boot之实现自动配置
  19. vue项目中引入第三方框架
  20. PAT 甲级 1023 Have Fun with Numbers(20)(思路分析)

热门文章

  1. 牛客多校第十场 D Han Xin and His Troops 中国剩余定理
  2. 修改ActiveProcessLinks链表隐藏进程
  3. 8张图带你轻松温习Java知识
  4. kettle 中 java.lang.ClassCastException: [B cannot be cast to java.lang.String报错的解决方法
  5. 通过Matlab SDK 获取tushare数据
  6. 通过Python SDK 获取tushare数据
  7. myeclipe 中配置maven
  8. 005-Java运算符
  9. MD5/SHA1/Hmac_SHA1
  10. mysql中重复数据只取条