Search in sources :

Example 6 with OAuthClient

use of net.oauth.client.OAuthClient in project ngtesting-platform by aaronchen2k.

the class AtlassianOAuthClient method swapRequestTokenForAccessToken.

public String swapRequestTokenForAccessToken(String requestToken, String tokenSecret, String oauthVerifier) {
    try {
        OAuthAccessor accessor = getAccessor();
        OAuthClient client = new OAuthClient(new HttpClient4());
        accessor.requestToken = requestToken;
        accessor.tokenSecret = tokenSecret;
        OAuthMessage message = client.getAccessToken(accessor, "POST", ImmutableList.of(new OAuth.Parameter(OAuth.OAUTH_VERIFIER, oauthVerifier)));
        return message.getToken();
    } catch (Exception e) {
        throw new RuntimeException("Failed to swap request token with access token", e);
    }
}
Also used : OAuthAccessor(net.oauth.OAuthAccessor) HttpClient4(net.oauth.client.httpclient4.HttpClient4) OAuthMessage(net.oauth.OAuthMessage) OAuthClient(net.oauth.client.OAuthClient)

Aggregations

OAuthAccessor (net.oauth.OAuthAccessor)6 OAuthClient (net.oauth.client.OAuthClient)6 OAuthMessage (net.oauth.OAuthMessage)4 HashMap (java.util.HashMap)3 OAuthConsumer (net.oauth.OAuthConsumer)3 OAuthServiceProvider (net.oauth.OAuthServiceProvider)3 URLConnectionClient (net.oauth.client.URLConnectionClient)3 HttpClient4 (net.oauth.client.httpclient4.HttpClient4)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 ModelAndView (org.springframework.web.servlet.ModelAndView)3 Cookie (javax.servlet.http.Cookie)1 OAuth (net.oauth.OAuth)1 OAuthResponseMessage (net.oauth.client.OAuthResponseMessage)1