I have installed some JHPers described on my homepage with some organizations. Frontend works great with AngularJS and API pages also allow me to test as expected of my services.
Now I am trying to write a rest client using Spring Restpetlet like this:
public list & lt; SomeEntity & gt; GetAllEntities () {URI uri = URI.create ("http: // localhost: 8080 / API / entities"); HTTP Header http Hudders = this.createHeaders ("Admin", "Admin") Progressive Distance & lt; SomeEntity [] & gt; Reactionanti = rest template. Exchange (Yuri, HTTP Math, GET, New HTTTTTT; LATTATTT (GHiders), Ententity []. Category); Return arrays.asList (responseEntity.getBody ()); } Private HTTP headers creation header (last string username, last string password) {HTTP header header = new HTTP header () {{string a youth = username}: "+ password; Byte [] EncodedAuthor = Base64. encode (auth.getBytes (charset.firename ("US-ASCII")); String authHeader = "basic" + new string (encoded); Set ("authorization", authHeader); }}; Headers.add ("content-type", "app / json"); Headers.add ("Accept", "App / JS"); Return headers; }
But this resulted in the following error: [Warning] org.springframework.web.client.RestTemplate - "Request for 401 received (unauthorized);
Now I'm not sure if and how I need to optimize my HTTP headers or if my simple fundamental rule is wrong to deal with all wrongdoing.
The way you authenticate it is incorrect, it seems that when you generate your app, Cleansing is selected, so for this, a form-based author is not required, because of being able to store session cookies and CSRF cookies is most likely to use the Commons HTT Client.
That will make it easy to choose xyoth token authentication when generating your app.
CORS issues will occur as soon as your customer will not run on the same host as your JHPSTER app.
No comments:
Post a Comment