Exemplo n.º 1
0
 /**
  * Returns the fully configured {@link OAuthService}
  *
  * @return fully configured {@link OAuthService}
  */
 public OAuthService build() {
   Preconditions.checkNotNull(api, "You must specify a valid api through the provider() method");
   Preconditions.checkEmptyString(apiKey, "You must provide an api key");
   Preconditions.checkEmptyString(apiSecret, "You must provide an api secret");
   return api.createService(
       new OAuthConfig(apiKey, apiSecret, callback, signatureType, scope, grantType, debugStream));
 }
Exemplo n.º 2
0
 private Api createApi(Class<? extends Api> apiClass) {
   Preconditions.checkNotNull(apiClass, "Api class cannot be null");
   Api api;
   try {
     api = apiClass.newInstance();
   } catch (Exception e) {
     throw new OAuthException("Error while creating the Api object", e);
   }
   return api;
 }
Exemplo n.º 3
0
 /**
  * Adds an OAuth callback url
  *
  * @param callback callback url. Must be a valid url or 'oob' for out of band OAuth
  * @return the {@link ServiceBuilder} instance for method chaining
  */
 public ServiceBuilder callback(String callback) {
   Preconditions.checkNotNull(callback, "Callback can't be null");
   this.callback = callback;
   return this;
 }
Exemplo n.º 4
0
 /**
  * Configures the {@link Api}
  *
  * <p>Overloaded version. Let's you use an instance instead of a class.
  *
  * @param api instance of {@link Api}s
  * @return the {@link ServiceBuilder} instance for method chaining
  */
 public ServiceBuilder provider(Api api) {
   Preconditions.checkNotNull(api, "Api cannot be null");
   this.api = api;
   return this;
 }
Exemplo n.º 5
0
 public ServiceBuilder debugStream(OutputStream stream) {
   Preconditions.checkNotNull(stream, "debug stream can't be null");
   this.debugStream = stream;
   return this;
 }
Exemplo n.º 6
0
 /**
  * Configures the signature type, choose between header, querystring, etc. Defaults to Header
  *
  * @param scope The OAuth scope
  * @return the {@link ServiceBuilder} instance for method chaining
  */
 public ServiceBuilder signatureType(SignatureType type) {
   Preconditions.checkNotNull(type, "Signature type can't be null");
   this.signatureType = type;
   return this;
 }