spring - j_spring_security_check resulted in 401 (Android) -


I am trying to login my API through the Spring Protection with the rest of the template. I'm able to successfully login to my web project, but not with the Android app. I am trying to solve this issue for a long time but could not figure it out.

Web Code:

@ etowire restamplate rest template; Multivellomap & lt; String, string & gt; LoginMap = New Link Value Value Validation & lt; String, string & gt; (); LoginMap.add ("j_username", j_username); LoginMap.add ("j_password", j_password); HttpEntity & LT ;? & Gt; UserEntity = New HttpEntity & lt; Object & gt; (Loginmap, new HTTP header ()); RestTemplate.postForObject (path + "/ j_spring_security_check", userEntity, String.class);

Android code:

  relaxation rest templates = new restaurants (); Multivellomap & lt; String, string & gt; LoginMap = New Link Value Value Validation & lt; String, string & gt; (); LoginMap.add ("j_username", this.mEmail); LoginMap.add ("j_password", this.mPassword); HttpEntity & LT ;? & Gt; UserEntity = New HttpEntity & lt; Object & gt; (Loginmap, new HTTP header ()); RestTemplate.getMessageConverters () Add (New MappingJackson HttpMessageConverter ()); RestTemplate.postForObject (path + "/ j_spring_security_check", userEntity, String.class);  

thanks

I fixed the problem with adding two more converters Of

Relaxation pure template template = newest rest template (); & Lt; HttpMessageConverter & LT ;? & Gt; & Gt; MessageConverters = New ArrayList & lt; HttpMessageConverter & lt ;? & Gt; & Gt; (); MessageConverters.add (new form HttpMessageConverter ()); MessageConverters.add (New String HTMLs Converter ()); MessageConverters.add (new mappingJacksonHttpMessageConverter ()); RestTemplate.setMessageConverters (messageConverters); Multivellomap & lt; String, string & gt; LoginMap = New Link Value Value Validation & lt; String, string & gt; (); LoginMap.add ("j_username", this.mEmail); LoginMap.add ("j_password", this.mPassword); HttpEntity & LT ;? & Gt; UserEntity = New HttpEntity & lt; Object & gt; (Loginmap, new HTTP header ()); RestTemplate.postForObject (path + "/ j_spring_security_check", userEntity, String.class);

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -