Package org.agorava.rest

Examples of org.agorava.rest.OAuthRequestImpl


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

    @InjectWithQualifier
    OAuthAppSettings config;

    @Override
    public Token getAccessToken(Token requestToken, Verifier verifier) {
        OAuthRequest request = new OAuthRequestImpl(api.getAccessTokenVerb(), api.getAccessTokenEndpoint());
        request.addBodyParameter(AgoravaConstants.CLIENT_ID, config.getApiKey());
        request.addBodyParameter(AgoravaConstants.CLIENT_SECRET, config.getApiSecret());
        request.addBodyParameter(AgoravaConstants.CODE, verifier.getValue());
        request.addBodyParameter(AgoravaConstants.REDIRECT_URI, config.getCallback());
        request.addBodyParameter("grant_type", "authorization_code");
        if (config.hasScope())
            request.addBodyParameter(AgoravaConstants.SCOPE, config.getScope());
        Response response = request.send(); //todo:should check return code and launch ResponseException if it's not 200
        return api.getAccessTokenExtractor().extract(response.getBody());
    }
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public Token getAccessToken(Token requestToken, Verifier verifier) {
        OAuthAppSettings config = getTunedOAuthAppSettings();
        OAuthRequest request = new OAuthRequestImpl(api.getAccessTokenVerb(), api.getAccessTokenEndpoint());
        request.addQuerystringParameter(AgoravaConstants.CLIENT_ID, config.getApiKey());
        request.addQuerystringParameter(AgoravaConstants.CLIENT_SECRET, config.getApiSecret());
        request.addQuerystringParameter(AgoravaConstants.CODE, verifier.getValue());
        request.addQuerystringParameter(AgoravaConstants.REDIRECT_URI, config.getCallback());
        if (config.hasScope())
            request.addQuerystringParameter(AgoravaConstants.SCOPE, config.getScope());
        Response response = request.send(); //todo:should check return code and launch ResponseException if it's not 200
        return api.getAccessTokenExtractor().extract(response.getBody());
    }
View Full Code Here

        extractor.extract(nullRequest);
    }

    @Test(expected = OAuthParametersMissingException.class)
    public void shouldThrowExceptionIfRquestHasNoOAuthParameters() {
        OAuthRequest request = new OAuthRequestImpl(Verb.GET, "http://example.com");
        extractor.extract(request);
    }
View Full Code Here

        extractor.extract(nullRequest);
    }

    @Test(expected = OAuthParametersMissingException.class)
    public void shouldExceptionIfRequestHasNoOAuthParams() {
        OAuthRequest emptyRequest = new OAuthRequestImpl(Verb.GET, "http://example.com");
        extractor.extract(emptyRequest);
    }
View Full Code Here

TOP

Related Classes of org.agorava.rest.OAuthRequestImpl

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.