0

I'm having trouble trying to connect with WP-API + JWT.

My request get a 401 response

"code":"rest_not_logged_in","message":"No estas conectado.","data":{"status":401}

Request headers:

Request URL:https://mysite/mywpsite/wp-json/wp/v2/users/me
Request Method:GET
Status Code:401 
Remote Address:77.104.154.224:443
Referrer Policy:no-referrer-when-downgrade

Response Headers
access-control-allow-credentials:true
access-control-allow-headers:Authorization, Content-Type
access-control-allow-methods:OPTIONS, GET, POST, PUT, PATCH, DELETE
access-control-allow-origin:http://localhost:8100
access-control-expose-headers:X-WP-Total, X-WP-TotalPages
allow:GET
cache-control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0
content-type:application/json; charset=UTF-8
date:Tue, 08 Aug 2017 18:26:36 GMT
expires:Thu, 19 Nov 1981 08:52:00 GMT
host-header:192fc2e7e50945beb8231a492d6a8024
link:<https://mysite/mywpsite/wp-json/>; rel="https://api.w.org/"
pragma:no-cache
server:nginx
set-cookie:PHPSESSID=m47mbn67jn9bs6hd4honundml2; path=/
status:401
vary:Origin
x-content-type-options:nosniff
x-robots-tag:noindex

Request Headers
:authority:mysite
:method:GET
:path:/mywpsite/wp-json/wp/v2/users/me
:scheme:https
accept:application/json, text/plain, */*
accept-encoding:gzip, deflate, br
accept-language:en-US,en;q=0.8,es-419;q=0.6,es;q=0.4
authorization:Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvZXN0ZWJhbnJvbWVyby5tZVwvYWRzYXBwIiwiaWF0IjoxNTAyMjE0MTc3LCJuYmYiOjE1MDIyMTQxNzcsImV4cCI6MTUwMjgxODk3NywiZGF0YSI6eyJ1c2VyIjp7ImlkIjoiMTAifX19.EUs5b26cHx1d8UObxpuXYGyb2UYGfzrdsAv6zPpqiBs
cache-control:no-cache
content-type:text/plain
origin:http://localhost:8100
pragma:no-cache
referer:http://localhost:8100/?ionicplatform=ios&ionicstatusbarpadding=true&http://localhost:8100/ionic-lab
user-agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36 

My host provider is Siteground, I already changed the .htaccess :

RewriteEngine on
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]

When I change to :

RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%0]

I get a 403 error :

I have no idea what i'm doing wrong, I really appreciate your help.

Nilesh Deokar
  • 2,975
  • 30
  • 53

1 Answers1

0

Install the plugin "JSON Basic Authentication", https://github.com/WP-API/Basic-Auth, and active and test.