/** {@inheritDoc} */ @Override public AccessToken getOAuthAccessToken(final String screenName, final String password) throws TwitterException { try { final String url = conf.getOAuthAccessTokenURL(); if (0 == url.indexOf("http://")) { // SSL is required // @see https://dev.twitter.com/docs/oauth/xauth // url = "https://" + url.substring(7); } final String sign_url = conf.getSigningOAuthAccessTokenURL(); if (0 == sign_url.indexOf("http://")) { // SSL is required // @see https://dev.twitter.com/docs/oauth/xauth // sign_url = "https://" + sign_url.substring(7); } oauthToken = new AccessToken( http.post( url, sign_url, new HttpParameter[] { new HttpParameter("x_auth_username", screenName), new HttpParameter("x_auth_password", password), new HttpParameter("x_auth_mode", "client_auth") }, this)); return (AccessToken) oauthToken; } catch (final TwitterException te) { throw new TwitterException( "The screen name / password combination seems to be invalid.", te, te.getStatusCode()); } }
/** {@inheritDoc} */ @Override public AccessToken getOAuthAccessToken() throws TwitterException { ensureTokenIsAvailable(); if (oauthToken instanceof AccessToken) return (AccessToken) oauthToken; oauthToken = new AccessToken( http.post(conf.getOAuthAccessTokenURL(), conf.getSigningOAuthAccessTokenURL(), this)); return (AccessToken) oauthToken; }
/** {@inheritDoc} */ @Override public AccessToken getOAuthAccessToken(final String oauthVerifier) throws TwitterException { ensureTokenIsAvailable(); final String url = conf.getOAuthAccessTokenURL(); if (0 == url.indexOf("http://")) { // SSL is required // @see https://dev.twitter.com/docs/oauth/xauth // url = "https://" + url.substring(7); } final String sign_url = conf.getSigningOAuthAccessTokenURL(); if (0 == sign_url.indexOf("http://")) { // SSL is required // @see https://dev.twitter.com/docs/oauth/xauth // sign_url = "https://" + sign_url.substring(7); } oauthToken = new AccessToken( http.post( url, sign_url, new HttpParameter[] {new HttpParameter("oauth_verifier", oauthVerifier)}, this)); return (AccessToken) oauthToken; }