PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, October 14, 2022

[FIXED] when user want to login : AXIOS ERROR: [Error: Request failed with status code 401] BAD_REQUEST

 October 14, 2022     axios, bad-request, docker-compose, react-native, reactjs     No comments   

Issue

i have a react native app and want to login EXISTING USER IN DATABASE with username and password for get the accesstoken and refreshtoken from api/login. but i get 401 error .

error in docker log:


    app_1       | 2022-06-23 20:56:55.997 ERROR 1 --- [nio-8080-exec-3] c.r.hamsafar
.service.UsersServiceImpl    : User Not Found In Database
app_1       | Hibernate:
app_1       |     select
app_1       |         users0_.id as id1_1_,
app_1       |         users0_.activation_code as activati2_1_,
app_1       |         users0_.active as active3_1_,
app_1       |         users0_.disabled as disabled4_1_,
app_1       |         users0_.failed_try_count as failed_t5_1_,
app_1       |         users0_.family as family6_1_,
app_1       |         users0_.lock_time as lock_tim7_1_,
app_1       |         users0_.name as name8_1_,
app_1       |         users0_.national_code as national9_1_,
app_1       |         users0_.password as passwor10_1_,
app_1       |         users0_.sms_time as sms_tim11_1_,
app_1       |         users0_.username as usernam12_1_
app_1       |     from
app_1       |         users users0_
app_1       |     where
app_1       |         users0_.username=?

This is while the user is in the database and it works with the same username and password correctly and without error in postman.

axios codes:

 var formData = new FormData();
  formData.append('username', '0123456789');
  formData.append('password', '0123456789');
  axios.post(
    'http://1.2.3.4:5555/api/login'
    , { formData })
    .then(response => {
          console.log("RESPONSE RECEIVED: ", response);
        })
        .catch((err) => {
          console.log("AXIOS ERROR: ", err);
        })

please help me


Solution

https://stackoverflow.com/users/6730803/fredrik-sch%c3%b6n

https://stackoverflow.com/users/10237430/abir-taheer

i solved my problem with used the username and password in url like this:

'http://1.2.3.4:5555/api/login?username='0123456789'&password='0123456789''

thank you from :

https://stackoverflow.com/users/6730803/fredrik-sch%c3%b6n

&

https://stackoverflow.com/users/10237430/abir-taheer

&

https://stackoverflow.com



Answered By - mrmiremad
Answer Checked By - Willingham (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing