예제 #1
0
 /**
  * Complete the connection to the OAuth1 provider.
  *
  * @param connectionFactory the service provider's connection factory e.g.
  *     FacebookConnectionFactory
  * @param request the current web request
  * @return a new connection to the service provider
  */
 public Connection<?> completeConnection(
     OAuth1ConnectionFactory<?> connectionFactory, NativeWebRequest request) {
   String verifier = request.getParameter("oauth_verifier");
   AuthorizedRequestToken requestToken =
       new AuthorizedRequestToken(extractCachedRequestToken(request), verifier);
   OAuthToken accessToken =
       connectionFactory.getOAuthOperations().exchangeForAccessToken(requestToken, null);
   return connectionFactory.createConnection(accessToken);
 }
예제 #2
0
 private String buildOAuth1Url(
     OAuth1ConnectionFactory<?> connectionFactory,
     NativeWebRequest request,
     MultiValueMap<String, String> additionalParameters) {
   OAuth1Operations oauthOperations = connectionFactory.getOAuthOperations();
   OAuth1Parameters parameters = new OAuth1Parameters(additionalParameters);
   if (oauthOperations.getVersion() == OAuth1Version.CORE_10) {
     parameters.setCallbackUrl(callbackUrl(request));
   }
   OAuthToken requestToken = fetchRequestToken(request, oauthOperations);
   request.setAttribute(OAUTH_TOKEN_ATTRIBUTE, requestToken, RequestAttributes.SCOPE_SESSION);
   return buildOAuth1Url(oauthOperations, requestToken.getValue(), parameters);
 }