Skip to content
Snippets Groups Projects
Commit e07641d7 authored by Emmanuel Bruno's avatar Emmanuel Bruno
Browse files

adds jwt to client.

parent 82c08694
No related branches found
No related tags found
No related merge requests found
...@@ -34,5 +34,26 @@ public class BiblioClient { ...@@ -34,5 +34,26 @@ public class BiblioClient {
.request() .request()
.get(Auteur.class); .get(Auteur.class);
log.info(auteur.toString()); log.info(auteur.toString());
//Log in to get the token
String email = "john.doe@nowhere.com";
String password = "admin";
String token = webResource.path("biblio/login")
.request()
.accept(MediaType.TEXT_PLAIN)
.header("Authorization", "Basic " + java.util.Base64.getEncoder().encodeToString((email + ":" + password).getBytes()))
.get(String.class);
if (!token.isBlank()) {
log.info("token received.");
//We access a JWT protected URL with the token
String result = webResource.path("biblio/secured")
.request()
.header("Authorization", "Bearer " + token)
.get(String.class);
log.info(result);
}
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment