Package org.agorava.api.oauth

Examples of org.agorava.api.oauth.OAuthRequest


    }

    @Override
    public void put(String uri, Object toPut, Object... urlParams) {
        uri = MessageFormat.format(uri, urlParams);
        OAuthRequest request = requestFactory(PUT, uri);

        request.addPayload(getJsonMapper().objectToJsonString(toPut));
        sendSignedRequest(request);

    }
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

        assertEquals(expected, baseString);
    }

    @Test(expected = IllegalArgumentException.class)
    public void shouldThrowExceptionIfRquestIsNull() {
        OAuthRequest nullRequest = null;
        extractor.extract(nullRequest);
    }
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

        }
    }

    @Test(expected = IllegalArgumentException.class)
    public void shouldExceptionIfRequestIsNull() {
        OAuthRequest nullRequest = null;
        extractor.extract(nullRequest);
    }
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.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.