コード例 #1
0
ファイル: OAuthService.java プロジェクト: plutext/scribejava
  public OAuthService(final OAuthConfig config) {
    this.config = config;
    final ForceTypeOfHttpRequest forceTypeOfHttpRequest =
        ScribeJavaConfig.getForceTypeOfHttpRequests();
    if (config instanceof OAuthConfigAsync) {
      if (ForceTypeOfHttpRequest.FORCE_SYNC_ONLY_HTTP_REQUESTS == forceTypeOfHttpRequest) {
        throw new OAuthException("Cannot use async operations, only sync");
      }
      if (ForceTypeOfHttpRequest.PREFER_SYNC_ONLY_HTTP_REQUESTS == forceTypeOfHttpRequest) {
        config.log("Cannot use async operations, only sync");
      }
      final OAuthConfigAsync asyncConfig = ((OAuthConfigAsync) config);
      final String asyncHttpProviderClassName = asyncConfig.getAsyncHttpProviderClassName();

      asyncHttpClient =
          asyncHttpProviderClassName == null
              ? new AsyncHttpClient(asyncConfig.getAsyncHttpClientConfig())
              : new AsyncHttpClient(
                  asyncHttpProviderClassName, asyncConfig.getAsyncHttpClientConfig());
    } else {
      if (ForceTypeOfHttpRequest.FORCE_ASYNC_ONLY_HTTP_REQUESTS == forceTypeOfHttpRequest) {
        throw new OAuthException("Cannot use sync operations, only async");
      }
      if (ForceTypeOfHttpRequest.PREFER_ASYNC_ONLY_HTTP_REQUESTS == forceTypeOfHttpRequest) {
        config.log("Cannot use sync operations, only async");
      }
    }
  }
コード例 #2
0
ファイル: DropboxApi20.java プロジェクト: pac4j/pac4j
 @Override
 public String getAuthorizationUrl(OAuthConfig oAuthConfig, Map<String, String> additionalParams) {
   return String.format(
       AUTH_URL + "?client_id=%s&response_type=code&redirect_uri=%s",
       oAuthConfig.getApiKey(),
       OAuthEncoder.encode(oAuthConfig.getCallback()));
 }
コード例 #3
0
  @Override
  public String getAuthorizationUrl(OAuthConfig config) {
    Preconditions.checkValidUrl(
        config.getCallback(),
        "Must provide a valid url as callback. Pinterest does not support OOB");

    // Append scope if present
    if (config.hasScope()) {
      return String.format(
          SCOPED_AUTHORIZE_URL,
          config.getApiKey(),
          OAuthEncoder.encode(config.getCallback()),
          OAuthEncoder.encode(config.getScope()));
    } else {
      return String.format(
          AUTHORIZE_URL, config.getApiKey(), OAuthEncoder.encode(config.getCallback()));
    }
  }
コード例 #4
0
 @Override
 public String getAuthorizationUrl(OAuthConfig config) {
   return String.format(
       AUTHORIZE_URL, config.getApiKey(), OAuthEncoder.encode(config.getCallback()));
 }