Package org.agorava.api.oauth

Examples of org.agorava.api.oauth.OAuthRequest


    public Token getRequestToken(RequestTuner tuner) {

        OAuthAppSettings config = getTunedOAuthAppSettings();
        LOGGER.fine("obtaining request token from " + api.getRequestTokenEndpoint());
        OAuthRequest request = requestFactory(api.getRequestTokenVerb(), api.getRequestTokenEndpoint());

        LOGGER.fine("setting oauth_callback to " + config.getCallback());
        request.addOAuthParameter(AgoravaConstants.CALLBACK, config.getCallback());
        addOAuthParams(request, AgoravaConstants.EMPTY_TOKEN);
        appendSignature(request);

        LOGGER.fine("sending request...");
        Response response = request.send(tuner);
        //todo:should check return code and launch ResponseException if it's not 200
        String body = response.getBody();

        LOGGER.fine("response status code: " + response.getCode());
        LOGGER.fine("response body: " + body);
View Full Code Here


        return getAccessToken(requestToken, verifier, 2, TimeUnit.SECONDS);
    }

    public Token getAccessToken(Token requestToken, Verifier verifier, RequestTuner tuner) {
        LOGGER.fine("obtaining access token from " + api.getAccessTokenEndpoint());
        OAuthRequest request = requestFactory(api.getAccessTokenVerb(), api.getAccessTokenEndpoint());
        request.addOAuthParameter(AgoravaConstants.TOKEN, requestToken.getToken());
        request.addOAuthParameter(AgoravaConstants.VERIFIER, verifier.getValue());

        LOGGER.fine("setting token to: " + requestToken + " and verifier to: " + verifier);
        addOAuthParams(request, requestToken);
        appendSignature(request);
        Response response = request.send(tuner);
        //todo:should check return code and launch ResponseException if it's not 200
        return api.getAccessTokenExtractor().extract(response.getBody());
    }
View Full Code Here

import org.agorava.rest.OAuthRequestImpl;

public class ObjectMother {

    public static OAuthRequest createSampleOAuthRequest() {
        OAuthRequest request = new OAuthRequestImpl(Verb.GET, "http://example.com");
        request.addOAuthParameter(AgoravaConstants.TIMESTAMP, "123456");
        request.addOAuthParameter(AgoravaConstants.CONSUMER_KEY, "AS#$^*@&");
        request.addOAuthParameter(AgoravaConstants.CALLBACK, "http://example/callback");
        request.addOAuthParameter(AgoravaConstants.SIGNATURE, "OAuth-Signature");
        return request;
    }
View Full Code Here

    private Map<String, String> requestHeader;

    @Override
    public OAuthRequest requestFactory(Verb verb, String uri) {
        OAuthRequest res = new OAuthRequestImpl(verb, uri);
        return res;
    }
View Full Code Here

        }
    }

    @Override
    public Response sendSignedRequest(Verb verb, String uri) {
        OAuthRequest request = requestFactory(verb, uri);
        return sendSignedRequest(request);

    }
View Full Code Here

    }

    @Override
    public Response sendSignedRequest(Verb verb, String uri, String key, Object value) {
        OAuthRequest request = requestFactory(verb, uri);

        request.addBodyParameter(key, value.toString());

        return sendSignedRequest(request);

    }
View Full Code Here

    }

    @Override
    public Response sendSignedXmlRequest(Verb verb, String uri, String payload) {
        OAuthRequest request = requestFactory(verb, uri);
        request.addPayload(payload);
        return sendSignedRequest(request);

    }
View Full Code Here

    }

    @Override
    public Response sendSignedRequest(Verb verb, String uri, Map<String, ? extends Object> params) {
        OAuthRequest request = requestFactory(verb, uri);
        for (Map.Entry<String, ? extends Object> ent : params.entrySet()) {
            request.addBodyParameter(ent.getKey(), ent.getValue().toString());
        }
        return sendSignedRequest(request);

    }
View Full Code Here

        return getJsonMapper().mapToObject(sendSignedRequest(GET, url), clazz);
    }

    @Override
    public <T> T post(String uri, Map<String, ? extends Object> params, Class<T> clazz) {
        OAuthRequest request = requestFactory(POST, uri);
        request.addBodyParameters(params);
        return getJsonMapper().mapToObject(sendSignedRequest(request), clazz);
    }
View Full Code Here

    @Override
    public String post(String uri, Object toPost, Object... urlParams) {

        uri = MessageFormat.format(uri, urlParams);
        OAuthRequest request = requestFactory(POST, uri);

        request.addPayload(getJsonMapper().objectToJsonString(toPost));
        Response response = sendSignedRequest(request);
        return response.getHeader("Location");
    }
View Full Code Here

TOP

Related Classes of org.agorava.api.oauth.OAuthRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.