Class AppExtensionService
-
- All Implemented Interfaces:
public final class AppExtensionService extends MobileService
Represents the app extension service which provides the ability to let the client code access some readonly resources with a dedicated OAuth token. The service can be used for Android widget development which needs the ability to make API calls to the mobile services without requiring the user secure store be opened with the user's passcode.
-
-
Field Summary
Fields Modifier and Type Field Description private OAuth2WebOptionwebOptionForAuthprivate BooleanenablePKCEForOAuth
-
Constructor Summary
Constructors Constructor Description AppExtensionService(AppConfig appConfig, Function1<List<AbstractOAuthClient>, OAuthClient> clientFilter, Function1<Boolean, Unit> serviceReadyListener)AppExtensionService(AppConfig appConfig, Function1<List<AbstractOAuthClient>, OAuthClient> clientFilter)AppExtensionService(AppConfig appConfig)AppExtensionService()
-
Method Summary
Modifier and Type Method Description final OAuth2WebOptiongetWebOptionForAuth()Choose between WebView or Browser for authentication final UnitsetWebOptionForAuth(OAuth2WebOption value)Choose between WebView or Browser for authentication final BooleangetEnablePKCEForOAuth()Set whether PKCE is enabled for OAuth final UnitsetEnablePKCEForOAuth(Boolean value)Set whether PKCE is enabled for OAuth Unitinit(Application application, String apiKey)Initializes the mobile service UnitonStateChange(ApplicationState state)Notified when application state changes. final UnitexchangeTokenForUser()Exchanges the host OAuth token for a readonly token scoped to the current user. Unitreset()Resets the service final UnitupdateAppConfig(AppConfig appConfig, Boolean replace)Updates the existing appConfig into the database. final UnitupdateAppConfig(AppConfig appConfig)Updates the existing appConfig into the database. final AppConfiggetAppConfig()Retrieves the current appConfig final AppExtensionServiceresumeService()Start/Resume the service. final AppExtensionServicepauseService()Pause the service, after paused, the service will not response to any application state changes. final OkHttpClientbuildReadonlyOkHttpClient()Retrieves the 'okhttp client' to access the readonly resources -
-
Constructor Detail
-
AppExtensionService
AppExtensionService(AppConfig appConfig, Function1<List<AbstractOAuthClient>, OAuthClient> clientFilter, Function1<Boolean, Unit> serviceReadyListener)
- Parameters:
appConfig- the optional app configuration information.clientFilter- the filter to determine which OAuth client to be used to get the tokens to access the readonly resources at the server side.serviceReadyListener- the callback listener which enables the client code response to the service ready or not status change.
-
AppExtensionService
AppExtensionService(AppConfig appConfig, Function1<List<AbstractOAuthClient>, OAuthClient> clientFilter)
- Parameters:
appConfig- the optional app configuration information.clientFilter- the filter to determine which OAuth client to be used to get the tokens to access the readonly resources at the server side.
-
AppExtensionService
AppExtensionService(AppConfig appConfig)
- Parameters:
appConfig- the optional app configuration information.
-
AppExtensionService
AppExtensionService()
-
-
Method Detail
-
getWebOptionForAuth
final OAuth2WebOption getWebOptionForAuth()
Choose between WebView or Browser for authentication
-
setWebOptionForAuth
final Unit setWebOptionForAuth(OAuth2WebOption value)
Choose between WebView or Browser for authentication
-
getEnablePKCEForOAuth
final Boolean getEnablePKCEForOAuth()
Set whether PKCE is enabled for OAuth
-
setEnablePKCEForOAuth
final Unit setEnablePKCEForOAuth(Boolean value)
Set whether PKCE is enabled for OAuth
-
init
Unit init(Application application, String apiKey)
Initializes the mobile service
-
onStateChange
Unit onStateChange(ApplicationState state)
Notified when application state changes. This function will be called on Main thread.
-
exchangeTokenForUser
final Unit exchangeTokenForUser()
Exchanges the host OAuth token for a readonly token scoped to the current user.
Call this when the host token has been renewed and the readonly token should be refreshed. Does nothing if the app is not configured with OAuth or if the network is unavailable.
-
reset
Unit reset()
Resets the service
-
updateAppConfig
@JvmOverloads() final Unit updateAppConfig(AppConfig appConfig, Boolean replace)
Updates the existing appConfig into the database.
-
updateAppConfig
@JvmOverloads() final Unit updateAppConfig(AppConfig appConfig)
Updates the existing appConfig into the database.
-
getAppConfig
final AppConfig getAppConfig()
Retrieves the current appConfig
-
resumeService
final AppExtensionService resumeService()
Start/Resume the service.
-
pauseService
final AppExtensionService pauseService()
Pause the service, after paused, the service will not response to any application state changes.
-
buildReadonlyOkHttpClient
final OkHttpClient buildReadonlyOkHttpClient()
Retrieves the 'okhttp client' to access the readonly resources
-
-
-
-