Andreea Onica
Andreea Onica

Reputation: 357

Authorization header malformed WP JWT Authentication for WP REST API

I have managed to get the token using user and pass and now I am passing the token using this ajax call in order to create a new post , like this :

$.ajax({
            url: "http://apibind.com/wp/wp-json/wp/v2/posts",
            type: "POST",               
            headers: { "Authorization": "Basic xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" },
            success: function (data) {
            console.log(data);
            },
            error:function(data){
              console.log(data);
            }
        });

and I get this error : Authorization header malformed . Anyone knows what is wrong with the header?

Upvotes: 0

Views: 4803

Answers (2)

zawhtut
zawhtut

Reputation: 8561

Remove the JWT related plugins from your WordPress(for my case , it's "Simple JWT Login"). They help if you are developing mobile apps for site but they interfere with the rest api call.

Upvotes: 0

Andreea Onica
Andreea Onica

Reputation: 357

simple misstake : Bearer instead of Basic (I'm using a token based authorization)

Upvotes: 1

Related Questions