spring-boot-spring-security-jwt-authentication icon indicating copy to clipboard operation
spring-boot-spring-security-jwt-authentication copied to clipboard

Signup posts generates 401

Open thomaschristensen opened this issue 2 years ago • 9 comments

When trying to create users following the example in the docs I get 401 on posting to /api/auth/signup

thomaschristensen avatar Jun 05 '23 15:06 thomaschristensen

Appears to be when username is shorter than 3 letters and this error does not end up in the returned message

thomaschristensen avatar Jun 05 '23 15:06 thomaschristensen

Hi, you can validate the request body. Kindly read following tutorial: https://www.bezkoder.com/spring-boot-validate-request-body/

tienbku avatar Jun 06 '23 01:06 tienbku

Getting 401 issue while calling singup api. any solutions can be suggested?

bsuriyakuts avatar Jul 14 '23 04:07 bsuriyakuts

Getting 401 issue while calling singup api. any solutions can be suggested?

curl --location 'localhost:8080/api/auth/signup' \ --header 'Content-Type: application/json' \ --header 'Cookie: JSESSIONID=89CC086CF0D4CF7D8A3E542AFA8CDF54' \ --data-raw '{ "username":"phiauphiau", "email":"[email protected]", "password":"phiauphiau", "role":[] }'

Above curl request work fine. Below getting the 401 as you.

curl --location --request POST 'localhost:8080/api/auth/signup?username=phiauphiau&email=phiau%40phiau.com&password=phiauphiau&role=ROLE_USER' \ --header 'Cookie: JSESSIONID=89CC086CF0D4CF7D8A3E542AFA8CDF54'

phiau avatar Aug 03 '23 02:08 phiau

Addon ValidationExceptionHandler Class. See in the article: https://www.bezkoder.com/spring-boot-validate-request-body/

lthchinchin avatar Feb 16 '24 14:02 lthchinchin

@thomaschristensen got the solution?

VitusJoy avatar May 07 '24 07:05 VitusJoy

No, but I haven't tried with newer versions

thomaschristensen avatar May 07 '24 09:05 thomaschristensen

No, but I haven't tried with newer versions

on java java -version java version "17.0.1" 2021-10-19 LTS Java(TM) SE Runtime Environment (build 17.0.1+12-LTS-39) Java HotSpot(TM) 64-Bit Server VM (build 17.0.1+12-LTS-39, mixed mode, sharing)

Screenshot 2024-05-07 at 4 30 24 PM

nothing on console

***property spring.datasource.url=jdbc:mysql://localhost:3306/DB_1?useSSL=false spring.datasource.username=root spring.datasource.password=PASSWORD spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect spring.jpa.hibernate.ddl-auto=update bezkoder.app.jwtSecret= ======================BezKoder=Spring=========================== bezkoder.app.jwtExpirationMs=86400000

VitusJoy avatar May 07 '24 11:05 VitusJoy