Package org.apache.oltu.oauth2.client

Examples of org.apache.oltu.oauth2.client.OAuthClient


            .setCode(Common.AUTHORIZATION_CODE)
            .setRedirectURI(Common.REDIRECT_URL)
            .setClientId(Common.CLIENT_ID)
            .buildBodyMessage();

        OAuthClient oAuthclient = new OAuthClient(new URLConnectionClient());

        try {
            oAuthclient.accessToken(request);
            fail("exception expected");
        } catch (OAuthProblemException e) {
            assertEquals(OAuthError.TokenResponse.INVALID_REQUEST, e.getError());
        }
    }
View Full Code Here


            .setRedirectURI(Common.REDIRECT_URL)
            .setCode("unknown_code")
            .setClientId(Common.CLIENT_ID)
            .buildBodyMessage();

        OAuthClient oAuthClient = new OAuthClient(new URLConnectionClient());

        try {
            oAuthClient.accessToken(request);
            fail("exception expected");
        } catch (OAuthProblemException e) {
            assertEquals(OAuthError.TokenResponse.INVALID_GRANT, e.getError());
        }
    }
View Full Code Here

                .setClientSecret("3acb294b071c9aec86d60ae3daf32a93")
                .setRedirectURI("http://localhost:8080/")
                .setCode(code)
                .buildBodyMessage();

            OAuthClient oAuthClient = new OAuthClient(new URLConnectionClient());

            //Facebook is not fully compatible with OAuth 2.0 draft 10, access token response is
            //application/x-www-form-urlencoded, not json encoded so we use dedicated response class for that
            //Own response class is an easy way to deal with oauth providers that introduce modifications to
            //OAuth specification
            GitHubTokenResponse oAuthResponse = oAuthClient.accessToken(request, GitHubTokenResponse.class);

            System.out.println(
                "Access Token: " + oAuthResponse.getAccessToken() + ", Expires in: " + oAuthResponse
                    .getExpiresIn());
        } catch (OAuthProblemException e) {
View Full Code Here

                .setClientId(parameters.clientId)
                .setClientSecret(parameters.clientSecret)
                .setRefreshToken(parameters.refreshToken)
                .buildBodyMessage();

        OAuthClient oAuthClient = getOAuthClient();

        OAuthToken oAuthToken = oAuthClient.accessToken(accessTokenRequest, OAuthJSONAccessTokenResponse.class).getOAuthToken();
        parameters.applyRetrievedAccessToken(oAuthToken.getAccessToken());
        parameters.setAccessTokenIssuedTimeInProfile(TimeUtils.getCurrentTimeInSeconds());
    }
View Full Code Here

    public void addBrowserListener(BrowserListener listener) {
        browserListeners.add(listener);
    }

    protected OAuthClient getOAuthClient() {
        return new OAuthClient(new HttpClient4(HttpClientSupport.getHttpClient()));
    }
View Full Code Here

        .setCode(getCode(request))
      .buildBodyMessage();

      logger.log(Level.INFO, "Request body: {0}", clientReq.getBody());

      OAuthClient oAuthClient = new OAuthClient(new URLConnectionClient());

      tokenResponse = oAuthClient.accessToken(clientReq, tokenResponseClass);
     
      logger.log(Level.INFO, "Access token response: {0}", tokenResponse.getBody());
     
      return tokenResponse;
     
View Full Code Here

        // needed for LinkedIn
        clientReq.setHeader("x-li-format", "json");
       
        logger.log(Level.INFO, "User info request: {0}", clientReq.getLocationUri());
       
        OAuthClient oAuthClient = new OAuthClient(new URLConnectionClient());

        userResponse = oAuthClient.resource(clientReq, "GET", OAuthResourceResponse.class);
        logger.log(Level.INFO, "User info response: {0}", userResponse);

        return userResponse;
       
      }
View Full Code Here

    }

    private String extractUsername(String code) {

        try {
            OAuthClient oAuthClient = new OAuthClient(new URLConnectionClient());

            OAuthClientRequest accessTokenRequest = OAuthClientRequest
                    .tokenLocation(accessTokenUrl)
                    .setGrantType(GrantType.AUTHORIZATION_CODE)
                    .setClientId(clientId)
View Full Code Here

            .setDescription(CommonExt.APP_DESCRIPTION)
            .setIcon(CommonExt.APP_ICON)
            .setRedirectURL(CommonExt.APP_REDIRECT_URI)
            .buildJSONMessage();

        OAuthRegistrationClient oauthclient = new OAuthRegistrationClient(new URLConnectionClient());
        OAuthClientRegistrationResponse response = oauthclient.clientInfo(request);

        assertEquals(CommonExt.CLIENT_ID, response.getClientId());
        assertEquals(CommonExt.CLIENT_SECRET, response.getClientSecret());
        assertEquals(CommonExt.EXPIRES_IN, response.getExpiresIn());
View Full Code Here

            .setDescription(CommonExt.APP_DESCRIPTION)
            .setIcon(CommonExt.APP_ICON)
            .setRedirectURL(CommonExt.APP_REDIRECT_URI)
            .buildBodyMessage();

        OAuthRegistrationClient oauthclient = new OAuthRegistrationClient(new URLConnectionClient());
        try {
            OAuthClientRegistrationResponse response = oauthclient.clientInfo(request);
            fail("exception expected");
        } catch (OAuthProblemException e) {
            assertNotNull(e.getError());
View Full Code Here

TOP

Related Classes of org.apache.oltu.oauth2.client.OAuthClient

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.