dongxi1320 2018-05-05 01:44
浏览 45

无法获取服务器来捕获授权头WP Rest API

I'm trying to develop an Android app for a WordPress/WooCommerce website. I can't seem to catch the Authorization header. I am using JWT Auth Plugin, I've set up the secret key and cors=true in wp-config.

define('JWT_AUTH_SECRET_KEY', 'qP>:$YKu7H%6#I&!i.delK^`Ehkm]k~4A*rJ3f<vJj+{ZKgTzRsEt<*PxRxhy;(t');
define('JWT_AUTH_CORS_ENABLE', true);

I've added every possible line I found on the internet to .htacces, currently I'm only with what the plugin requires, these are placed below "RewriteEngine On" and are at the top and above all others.

RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1

This was the common fix throughout all the people who had this problem. I tried Advanced Access Manager and it worked with it's customized Authentication header, but it returned "not logged in" when I tried /users/me with the token it gave me.

I've also tried editing class-jwt-auth-public.php file:

if (!$auth) {
    $allHeaders = getallheaders();
    $auth = isset($allHeaders['Authorization']) ? 
    $allHeaders['Authorization'] : false;
}

I'm using REST API LOG to analyze the requests and see that the Authorization header is not sent. Requests were sent with Postman and from my S7 Edge. I am losing my mind these few days trying to get this to work. Hopefully, you guys can help.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 基于卷积神经网络的声纹识别
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 stm32开发clion时遇到的编译问题