/** * Tests the call to obtain an authorized OAuth access token from a request token, namely a call * to POST /oauth/access_token. */ public void testOAuthAccessTokenCall() throws MalformedURLException { OAuthClientHelper och = new OAuthClientHelper(); och.setHttpMethod(HttpMethod.POST); och.setRequestUrl(new URL("https://staging.streamwork.com/oauth/access_token")); och.setConsumerKey("E4dKDaEitNJYqhqKJ2cw"); och.setConsumerSecret("julSfpM2z2C7YlJya8BcO4lMplvunMzPnQ4iEGWg"); // the request token och.setToken("KoRr6aAkMStAjR16ZxFY"); // the request token secret och.setTokenSecret("lgM0DiY9HJB0y9HjP7ps9LXrxdqOgn4FKBH5yFrk"); och.setSignatureMethod(SignatureMethod.HMAC_SHA1); och.setVerifier("J188mJCSgxzGIbjNmjoi"); // under normal circumstances, we would not set the timestamp and nonce, and just let the // library // use the current time and a generated uuid. However, we're comparing with a known good request och.setTimestamp(1303338681); och.setNonce("6UXq131D6A"); String expectedAuthorizationHeader = "OAuth oauth_consumer_key=\"E4dKDaEitNJYqhqKJ2cw\", oauth_nonce=\"6UXq131D6A\", oauth_signature_method=\"HMAC-SHA1\", oauth_timestamp=\"1303338681\", oauth_version=\"1.0\", oauth_token=\"KoRr6aAkMStAjR16ZxFY\", oauth_verifier=\"J188mJCSgxzGIbjNmjoi\", oauth_signature=\"9IXeoCfWbtjkt5otYmpeYG0k3jw%3D\""; assertEqualAuthorizationHeaders(expectedAuthorizationHeader, och.generateAuthorizationHeader()); }