Class ServiceBuilder
- java.lang.Object
-
- com.github.scribejava.core.builder.ServiceBuilder
-
- All Implemented Interfaces:
ServiceBuilderCommon,ServiceBuilderOAuth10a,ServiceBuilderOAuth20
public class ServiceBuilder extends java.lang.Object implements ServiceBuilderOAuth10a, ServiceBuilderOAuth20
Implementation of the Builder pattern, with a fluent interface that creates aOAuthService
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringapiKeyprivate java.lang.StringapiSecretprivate java.lang.Stringcallbackprivate java.io.OutputStreamdebugStreamprivate HttpClienthttpClientprivate HttpClientConfighttpClientConfigprivate java.lang.StringresponseTypeprivate java.lang.Stringscopeprivate java.lang.StringuserAgent
-
Constructor Summary
Constructors Constructor Description ServiceBuilder(java.lang.String apiKey)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ServiceBuilderapiKey(java.lang.String apiKey)Configures the api keyServiceBuilderapiSecret(java.lang.String apiSecret)Configures the api secretServiceBuilderapiSecretIsEmptyStringUnsafe()Configures the api secret as "" (empty string).OAuth10aServicebuild(DefaultApi10a api)OAuth20Servicebuild(DefaultApi20 api)ServiceBuildercallback(java.lang.String callback)Adds an OAuth callback urlServiceBuilderdebug()ServiceBuilderdebugStream(java.io.OutputStream debugStream)ServiceBuilderOAuth20defaultScope(ScopeBuilder scopeBuilder)ServiceBuilderOAuth20defaultScope(java.lang.String defaultScope)Configures the default OAuth 2.0 scope.
You can request any uniq scope per each access token request usingAuthorizationUrlBuilder.scope(java.lang.String).
In case you're requesting always the same scope,
you can just set it here and do not provide scope param nowhere more.ServiceBuilderhttpClient(HttpClient httpClient)takes precedence over httpClientConfigServiceBuilderhttpClientConfig(HttpClientConfig httpClientConfig)ServiceBuilderOAuth20responseType(java.lang.String responseType)private ServiceBuildersetScope(java.lang.String scope)ServiceBuilderuserAgent(java.lang.String userAgent)ServiceBuilderOAuth10awithScope(java.lang.String scope)Configures the OAuth 1.0a scope.
-
-
-
Field Detail
-
callback
private java.lang.String callback
-
apiKey
private java.lang.String apiKey
-
apiSecret
private java.lang.String apiSecret
-
scope
private java.lang.String scope
-
debugStream
private java.io.OutputStream debugStream
-
responseType
private java.lang.String responseType
-
userAgent
private java.lang.String userAgent
-
httpClientConfig
private HttpClientConfig httpClientConfig
-
httpClient
private HttpClient httpClient
-
-
Method Detail
-
callback
public ServiceBuilder callback(java.lang.String callback)
Description copied from interface:ServiceBuilderCommonAdds an OAuth callback url- Specified by:
callbackin interfaceServiceBuilderCommon- Specified by:
callbackin interfaceServiceBuilderOAuth10a- Specified by:
callbackin interfaceServiceBuilderOAuth20- Parameters:
callback- callback url. Must be a valid url or 'oob' (OAuthConstants.OOBfor out of band OAuth- Returns:
- the
ServiceBuilderinstance for method chaining
-
apiKey
public final ServiceBuilder apiKey(java.lang.String apiKey)
Description copied from interface:ServiceBuilderCommonConfigures the api key- Specified by:
apiKeyin interfaceServiceBuilderCommon- Specified by:
apiKeyin interfaceServiceBuilderOAuth10a- Specified by:
apiKeyin interfaceServiceBuilderOAuth20- Parameters:
apiKey- The api key for your application- Returns:
- the
ServiceBuilderinstance for method chaining
-
apiSecret
public ServiceBuilder apiSecret(java.lang.String apiSecret)
Description copied from interface:ServiceBuilderCommonConfigures the api secret- Specified by:
apiSecretin interfaceServiceBuilderCommon- Specified by:
apiSecretin interfaceServiceBuilderOAuth10a- Specified by:
apiSecretin interfaceServiceBuilderOAuth20- Parameters:
apiSecret- The api secret for your application- Returns:
- the
ServiceBuilderinstance for method chaining
-
apiSecretIsEmptyStringUnsafe
public ServiceBuilder apiSecretIsEmptyStringUnsafe()
Description copied from interface:ServiceBuilderCommonConfigures the api secret as "" (empty string). Used usually for a test environments or another strange cases. Not all providers support empty string as api key and will throw an Exception in such cases.- Specified by:
apiSecretIsEmptyStringUnsafein interfaceServiceBuilderCommon- Specified by:
apiSecretIsEmptyStringUnsafein interfaceServiceBuilderOAuth10a- Specified by:
apiSecretIsEmptyStringUnsafein interfaceServiceBuilderOAuth20- Returns:
- the
ServiceBuilderinstance for method chaining
-
setScope
private ServiceBuilder setScope(java.lang.String scope)
-
defaultScope
public ServiceBuilderOAuth20 defaultScope(java.lang.String defaultScope)
Description copied from interface:ServiceBuilderOAuth20Configures the default OAuth 2.0 scope.
You can request any uniq scope per each access token request usingAuthorizationUrlBuilder.scope(java.lang.String).
In case you're requesting always the same scope,
you can just set it here and do not provide scope param nowhere more.- Specified by:
defaultScopein interfaceServiceBuilderOAuth20- Parameters:
defaultScope- The OAuth scope, used as deafult- Returns:
- the
ServiceBuilderinstance for method chaining
-
defaultScope
public ServiceBuilderOAuth20 defaultScope(ScopeBuilder scopeBuilder)
- Specified by:
defaultScopein interfaceServiceBuilderOAuth20
-
withScope
public ServiceBuilderOAuth10a withScope(java.lang.String scope)
Description copied from interface:ServiceBuilderOAuth10aConfigures the OAuth 1.0a scope. This is only necessary in some APIs- Specified by:
withScopein interfaceServiceBuilderOAuth10a- Parameters:
scope- The OAuth scope- Returns:
- the
ServiceBuilderinstance for method chaining
-
debugStream
public ServiceBuilder debugStream(java.io.OutputStream debugStream)
- Specified by:
debugStreamin interfaceServiceBuilderCommon- Specified by:
debugStreamin interfaceServiceBuilderOAuth10a- Specified by:
debugStreamin interfaceServiceBuilderOAuth20
-
responseType
public ServiceBuilderOAuth20 responseType(java.lang.String responseType)
- Specified by:
responseTypein interfaceServiceBuilderOAuth20
-
httpClientConfig
public ServiceBuilder httpClientConfig(HttpClientConfig httpClientConfig)
- Specified by:
httpClientConfigin interfaceServiceBuilderCommon- Specified by:
httpClientConfigin interfaceServiceBuilderOAuth10a- Specified by:
httpClientConfigin interfaceServiceBuilderOAuth20
-
httpClient
public ServiceBuilder httpClient(HttpClient httpClient)
Description copied from interface:ServiceBuilderCommontakes precedence over httpClientConfig- Specified by:
httpClientin interfaceServiceBuilderCommon- Specified by:
httpClientin interfaceServiceBuilderOAuth10a- Specified by:
httpClientin interfaceServiceBuilderOAuth20- Parameters:
httpClient- externally created HTTP client- Returns:
- the
ServiceBuilderinstance for method chaining
-
userAgent
public ServiceBuilder userAgent(java.lang.String userAgent)
- Specified by:
userAgentin interfaceServiceBuilderCommon- Specified by:
userAgentin interfaceServiceBuilderOAuth10a- Specified by:
userAgentin interfaceServiceBuilderOAuth20
-
debug
public ServiceBuilder debug()
- Specified by:
debugin interfaceServiceBuilderCommon- Specified by:
debugin interfaceServiceBuilderOAuth10a- Specified by:
debugin interfaceServiceBuilderOAuth20
-
build
public OAuth10aService build(DefaultApi10a api)
- Specified by:
buildin interfaceServiceBuilderOAuth10a
-
build
public OAuth20Service build(DefaultApi20 api)
- Specified by:
buildin interfaceServiceBuilderOAuth20
-
-