How do you get a token for POST postman request?



  • Java app. application.yml

    server:
      port: 9000
    

    platform. properties

    jwt.secret="......."
    jwt.expiration.time=864000000
    jwt.header.prefix=Bearer
    jwt.header=my_token
    

    Controller

    @PostMapping("/login")
    public Result login(@RequestBody LoginRequestDto user){
        return userService.login(user);
    }
    

    From Postman, try to send a request to POST http://188.130.139.104:9000/login

    On deposit, the Authorization chooses Type: Basic Auth введите сюда описание изображения

    Filling field Username and Password As a result, received

    Could not send request
    


  • Basic Auth is different. It's built at the "Security". A simple example can be seen. https://www.baeldung.com/spring-security-basic-authentication ♪

    In your example, you're waiting on LoginRequestDto's request. That is, the body of POST ' s request should not be filled with copying.

    {
      "username": "user",
      "password": "paswd"
    }
    

    Names of fields as LoginRequestDto



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2