Closed masithedeveloper closed 6 years ago
How do you get the jwt token? I think this should works with the official frontend application.
I was wondering the same at first. I got it running like this:
application.properties
and add spring.h2.console.enabled=true
to enable the h2 consoleWebSecurityConfig.java
and add the following lines to the configure
method to allow access to the h2 console:
.antMatchers("/h2-console", "/h2-console/**")
.permitAll()
(before .anyRequest().authenticated()
)
and
.and()
.headers().frameOptions().sameOrigin();
(after .anyRequest().authenticated()
)
./gradlew bootRun
http://localhost:8080/h2-console
and create a new userhttp://localhost:8080/users/login
with body {"user":{"email":"{{EMAIL}}", "password":"{{PASSWORD}}"}}
(not /api/users/login
)Voila, you get the user with the JWT in the body!
@darioseidl so you are using the official frontend to access /users/login
or from the backend api?
I haven't tried any frontend yet. I was just running the backend and using the Postman collection from https://github.com/gothinkster/realworld/tree/master/api
I get a 401 error code when logging in, how do I use the JWT secret key provided in application.properties file?