public class ApiClient extends Object
| Constructor and Description |
|---|
ApiClient() |
ApiClient(String authName)
Basic constructor for single auth name
|
ApiClient(String[] authNames) |
ApiClient(String authName,
String apiKey)
Helper constructor for single api key
|
ApiClient(String authName,
String username,
String password)
Helper constructor for single basic auth or password oauth2
|
ApiClient(String authName,
String clientId,
String secret,
String username,
String password)
Helper constructor for single password oauth2
|
| Modifier and Type | Method and Description |
|---|---|
void |
addAuthorization(String authName,
okhttp3.Interceptor authorization)
Adds an authorization to be used by the client
|
void |
addAuthsToOkBuilder(okhttp3.OkHttpClient.Builder okBuilder) |
void |
configureAuthorizationFlow(String clientId,
String clientSecret,
String redirectURI)
Helper method to configure the oauth accessCode/implicit flow parameters
|
void |
configureFromOkclient(okhttp3.OkHttpClient okClient)
Clones the okBuilder given in parameter, adds the auth interceptors and uses it to configure the Retrofit
|
void |
createDefaultAdapter() |
<S> S |
createService(Class<S> serviceClass) |
retrofit2.Retrofit.Builder |
getAdapterBuilder() |
Map<String,okhttp3.Interceptor> |
getApiAuthorizations() |
org.apache.oltu.oauth2.client.request.OAuthClientRequest.AuthenticationRequestBuilder |
getAuthorizationEndPoint()
Helper method to configure authorization endpoint of the first oauth found in the apiAuthorizations (there should be only one)
|
okhttp3.OkHttpClient.Builder |
getOkBuilder() |
org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilder |
getTokenEndPoint()
Helper method to configure the token endpoint of the first oauth found in the apiAuthorizations (there should be only one)
|
void |
registerAccessTokenListener(OAuth.AccessTokenListener accessTokenListener)
Configures a listener which is notified when a new access token is received.
|
void |
setAccessToken(String accessToken)
Helper method to pre-set the oauth access token of the first oauth found in the apiAuthorizations (there should be only one)
|
void |
setAdapterBuilder(retrofit2.Retrofit.Builder adapterBuilder) |
void |
setApiAuthorizations(Map<String,okhttp3.Interceptor> apiAuthorizations) |
public ApiClient()
public ApiClient(String[] authNames)
public ApiClient(String authName)
authName - Authentication namepublic ApiClient(String authName, String apiKey)
authName - Authentication nameapiKey - API keypublic ApiClient(String authName, String username, String password)
authName - Authentication nameusername - Usernamepassword - Passwordpublic void createDefaultAdapter()
public <S> S createService(Class<S> serviceClass)
public org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilder getTokenEndPoint()
public org.apache.oltu.oauth2.client.request.OAuthClientRequest.AuthenticationRequestBuilder getAuthorizationEndPoint()
public void setAccessToken(String accessToken)
accessToken - Access tokenpublic void configureAuthorizationFlow(String clientId, String clientSecret, String redirectURI)
clientId - Client IDclientSecret - Client secretredirectURI - Redirect URIpublic void registerAccessTokenListener(OAuth.AccessTokenListener accessTokenListener)
accessTokenListener - Access token listenerpublic void addAuthorization(String authName, okhttp3.Interceptor authorization)
authName - Authentication nameauthorization - Authorization interceptorpublic void setApiAuthorizations(Map<String,okhttp3.Interceptor> apiAuthorizations)
public retrofit2.Retrofit.Builder getAdapterBuilder()
public void setAdapterBuilder(retrofit2.Retrofit.Builder adapterBuilder)
public okhttp3.OkHttpClient.Builder getOkBuilder()
public void addAuthsToOkBuilder(okhttp3.OkHttpClient.Builder okBuilder)
public void configureFromOkclient(okhttp3.OkHttpClient okClient)
okClient - An instance of OK HTTP clientCopyright © 2017. All rights reserved.