Title: Username returns empty
Last modified: January 9, 2022

---

# Username returns empty

 *  Resolved [katanga1987](https://wordpress.org/support/users/katanga1987/)
 * (@katanga1987)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/username-returns-empty/)
 * Building an Ionic Angular based app and struggling with login.
    Registration 
   works just fine on a largely similar code setup but login keeps retuning a 403
   error with username being empty.
 * code snippet below where values being set I believe. any help would be appreciated.
 * Created the below in an auth.service.ts file
 *     ```
           // Login to account service
           loginFixxrCustomer(email, username, password) {
             // Set Http headers
             let headers = new HttpHeaders({
               'Content-Type': 'application/x-www-form--urlencoded'
             });
   
             // Set values for credentials for user
             let credentials = <code>username=${username}&email=${email}&password=${password}</code>;
   
             // Create API Call
             this.apiUrl = <code>${this.siteUrl}/wp-json/jwt-auth/v1/token</code>;
             console.log('API URL: ', this.apiUrl);
   
             // Authenticate response
             return new Promise ((resolve) => {
               this.http.post(this.apiUrl, credentials, {headers}).subscribe((successResp) => {
                 resolve(successResp);
               },
               (errorResp) => {
                 resolve(errorResp);
               }
               )
             });
           }
       ```
   
 * Then run this on login.page.ts.
 *     ```
         // Login to account function
         wooLoginAcc () {
           this.platform.ready().then(() => {
             if(
               (this.username != '') &&
               (this.password != '') &&
               (this.CF.validateEmail(this.email))
             ) {
               console.log('Username', this.username);
               console.log('Email', this.email);
               console.log('Password', this.password);
   
               this.auth.loginFixxrCustomer(this.email,this.username,this.password).then((response) => {
                 if(response['token']) {
                   this.CF.presentToast('Login Successful.', true, 'bottom', 2000);
                   console.log('Login token: ', response['token']);
                   console.log('Login email: ', response['user_email']);
                   this.router.navigateByUrl('/home');
                 } else {
                   this.CF.presentToast('Login failed.', true, 'bottom', 20000);
                   console.log('Login failed.');
                 }
               });
             } else {
               this.CF.presentToast('Complete the form correctly please.', true, 'bottom', 5000);
               console.log('Form not completed correctly.');
             }
           });
         }
       ```
   

Viewing 1 replies (of 1 total)

 *  Thread Starter [katanga1987](https://wordpress.org/support/users/katanga1987/)
 * (@katanga1987)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/username-returns-empty/#post-15235534)
 * I managed to figure it out. Super tiny tweak to what was there.
 *     ```
         // Login to account service
           loginFixxrCustomer(email, username, password) {
             // Set Http headers
             //let headers = new HttpHeaders({
             //  'Content-Type': 'application/json'
             //});
   
             // Set values for credentials for user
             //let credentials = <code>username=${username}&email=${email}&password=${password}</code>;
   
             // Create API Call
             this.apiUrl = <code>${this.siteUrl}/wp-json/jwt-auth/v1/token</code>;
             console.log('API URL: ', this.apiUrl);
   
             // Authenticate response
             return new Promise ((resolve) => {
               this.http.post(this.apiUrl, {username, email, password}).subscribe((successResp) => {
                 resolve(successResp);
               },
               (errorResp) => {
                 resolve(errorResp);
               }
               )
             });
           }
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Username returns empty’ 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
 * 1 participant
 * Last reply from: [katanga1987](https://wordpress.org/support/users/katanga1987/)
 * Last activity: [4 years, 5 months ago](https://wordpress.org/support/topic/username-returns-empty/#post-15235534)
 * Status: resolved