nydiarra / springboot-jwt

Example Springboot Application for Securing a REST API with JSON Web Token (JWT). For an example Integration with Angular (version 2+) go to https://github.com/ipassynk/angular-springboot-jwt
548 stars 330 forks source link

How to get JWT token using Rest Timeplate? #7

Open Najeeb-Idrees opened 6 years ago

Najeeb-Idrees commented 6 years ago

I am using http://testjwtclientid:XY7kmzoNzl100@localhost:9999/oauth/token url and send { "password":"jwtpass ", "username":"john.doe", "grant_type":"password" } as a body.

Following is my java code.

String url = protocol + clientId + ":" + clientSecret + "@" + url + "/oauth/token"; restTemplate.exchange(url, HttpMethod.POST, entity, String.class);

But it gave me 401 always.

ShanGor commented 6 years ago

i believe that you can ref to the readme.md file, use curl to test first, then use ur java code to test. the body should be urlencoded format instead of jason