Title: [jwt_auth] empty_username
Last modified: August 25, 2018

---

# [jwt_auth] empty_username

 *  [ponzo](https://wordpress.org/support/users/ponzo/)
 * (@ponzo)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/jwt_auth-empty_username/)
 * I tried to post to ‘/wp/wp-json/jwt-auth/v1/token’ with axios,
 * But it seems that the username isnt coming trough, or at least in the headers
   I see there are slashes added
 * {\”username\”:\”email@email.com\”,\”password\”:\”Supersecretpassword\”}
 * In postman it works, the example gives me and encoded string
    var data = “password
   =Supersecretpassword&username=email@email.com”;
 * When i encode my object before sending it to axios it works!
 *  var str = Object.keys(requestBody).map(function (key) {
    return encodeURIComponent(
   key) + ‘=’ + encodeURIComponent(requestBody[key]) }).join(‘&’);
 * So if anyone has the same problem, below works
 *  const requestBody = {
    “username”: formdata.email, “password”:formdata.password}
 *  const config = {
    headers: { ‘Content-Type’: ‘application/x-www-form-urlencoded’},
   withCredentials: false }
 *  //otherwise the ‘username’ is incorrect,
    var str = Object.keys(requestBody).
   map(function (key) { return encodeURIComponent(key) + ‘=’ + encodeURIComponent(
   requestBody[key]) }).join(‘&’);
 *  axios.post(url, requestBody, config)
    .then((result) => {

Viewing 1 replies (of 1 total)

 *  [Ayodehi](https://wordpress.org/support/users/ayodehi/)
 * (@ayodehi)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/jwt_auth-empty_username/#post-11021899)
 * I stumbled across the same problem when testing with Postman. Obvious in retrospect,
   but you must set your content type to ‘application/json’. Easy to overlook!

Viewing 1 replies (of 1 total)

The topic ‘[jwt_auth] empty_username’ is closed to new replies.

 * ![](https://ps.w.org/jwt-authentication-for-wp-rest-api/assets/icon-256x256.jpg?
   rev=3372068)
 * [JWT Authentication for WP REST API](https://wordpress.org/plugins/jwt-authentication-for-wp-rest-api/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/jwt-authentication-for-wp-rest-api/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/jwt-authentication-for-wp-rest-api/)
 * [Active Topics](https://wordpress.org/support/plugin/jwt-authentication-for-wp-rest-api/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/jwt-authentication-for-wp-rest-api/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/jwt-authentication-for-wp-rest-api/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Ayodehi](https://wordpress.org/support/users/ayodehi/)
 * Last activity: [7 years, 3 months ago](https://wordpress.org/support/topic/jwt_auth-empty_username/#post-11021899)
 * Status: not resolved