I have a server using spring frmework and implmenting the OAuth 2.0 login approach. I need to make login to this server using Android device. I am already loging in using spring client and the code:
@RequestMapping(path="/login", method=RequestMethod.POST)
public String login(@RequestParam String email, @RequestParam String password, HttpSession session) {
ResourceOwnerPasswordResourceDetails details = new ResourceOwnerPasswordResourceDetails();
details.setId("oauthTest/client");
details.setClientId("my-trusted-client-with-secret");
details.setClientSecret("somesecret");
details.setAccessTokenUri("http://localhost:8080/FoReServer/oauth/token");
details.setScope(Arrays.asList("read", "write", "trust"));
details.setUsername(email);
details.setPassword(password);
OAuth2RestTemplate template = new OAuth2RestTemplate(details, oAuth2ClientContext);
template.getOAuth2ClientContext().setAccessToken(template.getAccessToken());
User user = template.getForObject("http://localhost:8080/FoReServer/api/rest/user/findMe", User.class);
session.setAttribute("user", user);
but i do not know what is the equivalent of this code in Android client to connect to Oauth 2.0 on server. I mean how can i send the user name and password to the spring server from Android client. And which android api classes i sould use for this case? Definitely HttpUrlConnection won't work !