Back to project page ReadabilitySDK.
The source code is released under:
MIT License
If you think the Android project ReadabilitySDK listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.idemidov.readability.command; /*from w ww. j av a2 s .c o m*/ import com.idemidov.readability.parser.AuthParser; import com.idemidov.readability.parser.Parser; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.message.BasicNameValuePair; import org.json.JSONException; import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import oauth.signpost.OAuthConsumer; import oauth.signpost.commonshttp.CommonsHttpOAuthConsumer; import oauth.signpost.exception.OAuthCommunicationException; import oauth.signpost.exception.OAuthExpectationFailedException; import oauth.signpost.exception.OAuthMessageSignerException; /** * Created by Ilya on 25/02/14. */ public class AuthCommand extends BaseCommand<HashMap<String, String>> { public static String OAUTH_TOKEN = "oauth_token"; public static String OAUTH_TOKEN_SECRET = "oauth_token_secret"; private String userName, password; public AuthCommand(OAuthConsumer consumer, String userName, String password) { super(consumer); this.userName = userName; this.password = password; } @Override Parser<HashMap<String, String>> getParser() { return new AuthParser(); } @Override String getUrl() { return ROOT_URL.concat("oauth/access_token/"); } @Override HttpUriRequest getHttpUriRequest() throws UnsupportedEncodingException { HttpPost post = new HttpPost(getUrl()); List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>(); params.add(new BasicNameValuePair("x_auth_username", userName)); params.add(new BasicNameValuePair("x_auth_password", password)); params.add(new BasicNameValuePair("x_auth_mode", "client_auth")); UrlEncodedFormEntity query = new UrlEncodedFormEntity(params); post.setEntity(query); return post; } }