Examples of OAuthService


Examples of org.scribe.oauth.OAuthService

          final String clientSecret = clientSecretEngineSettingValue.getValue();
          final String permissions = permissionsEngineSettingValue.getValue();
         
          final String windowsLiveCallBackURL = urlService.buildAbsoluteUrl(requestData, urlService.buildOAuthCallBackUrl(requestData, OAuthType.WINDOWS_LIVE.getPropertyKey().toLowerCase()));

            OAuthService service = new ServiceBuilder()
                    .provider(LiveApi.class)
                    .apiKey(clientId)
                    .apiSecret(clientSecret)
                    .scope(permissions)
                    .callback(windowsLiveCallBackURL)
                    .build();
         
          // Obtain the Authorization URL
          String authorizationUrl = service.getAuthorizationUrl(EMPTY_TOKEN);

          response.sendRedirect(authorizationUrl);
          }

      } catch (Exception e) {
View Full Code Here

Examples of org.scribe.oauth.OAuthService

          final String clientSecret = clientSecretEngineSettingValue.getValue();
          final String permissions = permissionsEngineSettingValue.getValue();
         
            final String googleAccountCallBackURL = urlService.buildAbsoluteUrl(requestData, urlService.buildOAuthCallBackUrl(requestData, OAuthType.GOOGLE_ACCOUNT.getPropertyKey().toLowerCase()));

              OAuthService service = new ServiceBuilder()
              .provider(Google2Api.class)
              .apiKey(clientId)
              .apiSecret(clientSecret)
              .scope(permissions)
                .callback(googleAccountCallBackURL)
                .build();

                    // Obtain the Authorization URL
                    String authorizationUrl = service.getAuthorizationUrl(EMPTY_TOKEN);

                    response.sendRedirect(authorizationUrl);
          }

      } catch (Exception e) {
View Full Code Here

Examples of org.scribe.oauth.OAuthService

        if (Constants.EVERNOTE_SERVICE == EvernoteService.PRODUCTION) {
          providerClass = org.scribe.builder.api.EvernoteApi.class;
        }


        OAuthService service = new ServiceBuilder()
            .provider(providerClass)
            .apiKey(Constants.EVERNOTE_CONSUMER_KEY)
            .apiSecret(Constants.EVERNOTE_CONSUMER_SECRET)
            .callback(cbUrl)
            .build();

        // 一時トークンを生成
        Token scribeRequestToken = service.getRequestToken();

        // OAuth承認のためのSecretを取得してセッションに保存
        sessionScope("evernoteRequestTokenSecret", scribeRequestToken.getSecret());

        // 承認画面
View Full Code Here

Examples of org.scribe.oauth.OAuthService

        if (Constants.EVERNOTE_SERVICE == EvernoteService.PRODUCTION) {
          providerClass = org.scribe.builder.api.EvernoteApi.class;
        }


        OAuthService service = new ServiceBuilder()
            .provider(providerClass)
            .apiKey(Constants.EVERNOTE_CONSUMER_KEY)
            .apiSecret(Constants.EVERNOTE_CONSUMER_SECRET)
            .callback(cbUrl)
            .build();

        String oauthToken = request.getParameter("oauth_token");
        String requestTokenSecret = sessionScope("evernoteRequestTokenSecret");
        String verifier = asString("oauth_verifier");

        // アクセストークンの取得
        Token scribeRequestToken = new Token(oauthToken, requestTokenSecret);
        Verifier scribeVerifier = new Verifier(verifier);
        Token scribeAccessToken = service.getAccessToken(scribeRequestToken, scribeVerifier);
        EvernoteAuth evernoteAuth = EvernoteAuth.parseOAuthResponse(Constants.EVERNOTE_SERVICE, scribeAccessToken.getRawResponse());

        return evernoteAuth;
    }
View Full Code Here

Examples of org.scribe.oauth.OAuthService

        System.out.println("Paste the consumerSecret here");
        System.out.print(">>");
        String apiSecret = in.nextLine();

        OAuthService service = new ServiceBuilder()
            .provider(YammerApi.class)
            .apiKey(apiKey)
            .apiSecret(apiSecret)
            .build();

        String authorizationUrl = service.getAuthorizationUrl(EMPTY_TOKEN);
        System.out
                .println("Go and authorize your app here (eg. in a web browser):");
        System.out.println(authorizationUrl);
        System.out.println("... and paste the authorization code here");
        System.out.print(">>");
        Verifier verifier = new Verifier(in.nextLine());

        System.out.println();

        Token accessToken = service.getAccessToken(EMPTY_TOKEN, verifier);
        System.out.println("Your Access Token is: " + accessToken);
        System.out.println();

        in.close();
    }
View Full Code Here

Examples of org.scribe.oauth.OAuthService

                String consumerKey = prop.getProperty("oauth.consumer.key");
                String consumerSecret = prop.getProperty("oauth.consumer.secret");
                in.close();

    System.setProperty("debug", "true");
    OAuthService service = new ServiceBuilder()
          .provider(KivaApi.class)
          .apiKey(consumerKey)
          .apiSecret(consumerSecret)
                .callback("oob")
          .debug()
          .build();
    Token token = service.getRequestToken();
  }
View Full Code Here

Examples of org.scribe.oauth.OAuthService

        String path = request.getPathInfo().replace("/", "");
       
        if (OAuthRealm.LOG.isTraceEnabled())
          OAuthRealm.LOG.trace("the " + request.getMethod() + " method, path info "+path);
       
        OAuthService service =
        OAuthRealm._.getServiceBulderByPath(path)
          .getServiceBuilder()
          .callback(request.getRequestURL().toString())
          .build();
       
        if (request.getParameterMap().containsKey(RETURN_TO_PAGE)) {

          String authorizationUrl = service.getAuthorizationUrl(EMPTY_TOKEN);
         
          request.getSession().setAttribute(RETURN_TO_PAGE, request.getParameter(RETURN_TO_PAGE));

          response.sendRedirect(authorizationUrl);
          return;
        }
       
        String verification = request.getParameter("code");
       
        Verifier verifier = new Verifier(verification);
        Token accessToken = null;
        //workaround google API
        if (OAuthRealm._.getServiceBulderByPath(path).provider.equalsIgnoreCase("google")) {
          Google2Api api = new Google2Api();
         
          Service config = OAuthRealm._.getServiceBulderByPath(path);

          OAuthRequest req = new OAuthRequest(api.getAccessTokenVerb(), api.getAccessTokenEndpoint());
          req.addBodyParameter(OAuthConstants.CLIENT_ID, config.getApiKey());
          req.addBodyParameter(OAuthConstants.CLIENT_SECRET, config.getApiSecret());
          req.addBodyParameter(OAuthConstants.CODE, verifier.getValue());
    // jetty.port.jetty
          req.addBodyParameter(OAuthConstants.REDIRECT_URI, config.getReturnURL());
          req.addBodyParameter("grant_type", "authorization_code");
         
          String responce = req.send().getBody();

          JSONTokener tokener = new JSONTokener(responce);
          try {
              JSONObject root = new JSONObject(tokener);
              String access_token = root.getString("access_token");

              String token = OAuthEncoder.decode(access_token);
              accessToken = new Token(token, "", responce);

          } catch (JSONException e) {
              throw new IOException(e);
          }
         
          //accessToken = api.getAccessTokenExtractor().extract(req.send().getBody());
        } else
            accessToken = service.getAccessToken(EMPTY_TOKEN, verifier);
       
        try {
            OAuthRealm._.getServiceBulderByPath(path).saveAccessToken(request, service, accessToken);
        } catch (Exception e) {
            throw new ServletException(e);
View Full Code Here

Examples of org.scribe.oauth.OAuthService

    EntityManager em;

    @RequestMapping(value = "/token")
    public String getEvernoteToken(HttpServletRequest request) throws IOException, ServletException {
        final Boolean sandbox = Boolean.valueOf(env.get(EVERNOTE_SANDBOX_KEY));
        OAuthService service = new ServiceBuilder()
                .provider(sandbox?EvernoteApi.Sandbox.class:EvernoteApi.class)
                .apiKey(getConsumerKey())
                .apiSecret(getConsumerSecret())
                .callback(env.get("homeBaseUrl") + "evernote/upgradeToken")
                .build();
        request.getSession().setAttribute(EVERNOTE_SERVICE, service);

        // Obtain the Authorization URL
        Token requestToken = service.getRequestToken();
        request.getSession().setAttribute(EVERNOTE_REQUEST_TOKEN, requestToken);
        String authorizationUrl = service.getAuthorizationUrl(requestToken);
        final String apiKeyIdParameter = request.getParameter("apiKeyId");
        if (apiKeyIdParameter!=null)
            request.getSession().setAttribute(EVERNOTE_RENEWTOKEN_APIKEYID, apiKeyIdParameter);

        return "redirect:" + authorizationUrl;
View Full Code Here

Examples of org.scribe.oauth.OAuthService

    @RequestMapping(value = "/upgradeToken")
    public String upgradeToken(HttpServletRequest request) throws IOException {
        final String code = request.getParameter("oauth_verifier");
        Verifier verifier = new Verifier(code);
        OAuthService service = (OAuthService)request.getSession().getAttribute(EVERNOTE_SERVICE);

        Token requestToken = (Token)request.getSession().getAttribute(EVERNOTE_REQUEST_TOKEN);
        Token accessToken = service.getAccessToken(requestToken, verifier);

        final String token = accessToken.getToken();

        Guest guest = AuthHelper.getGuest();
View Full Code Here

Examples of org.scribe.oauth.OAuthService

        final String accessToken = guestService.getApiKeyAttribute(updateInfo.apiKey, "accessToken");
        final Token token = new Token(accessToken, guestService.getApiKeyAttribute(updateInfo.apiKey, "runkeeperConsumerSecret"));
        final String userEndpoint = url + accessToken;
        OAuthRequest request = new OAuthRequest(Verb.GET, userEndpoint);
        request.addHeader("Accept", "application/vnd.com.runkeeper.User+json");
        final OAuthService service = runKeeperController.getOAuthService();
        service.signRequest(token, request);
        Response response = request.send();
        final int httpResponseCode = response.getCode();
        long then = System.currentTimeMillis();
        String body = response.getBody();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.