Authgear

class Authgear @JvmOverloads constructor(application: Application, clientId: String, authgearEndpoint: String, tokenStorage: TokenStorage = PersistentTokenStorage(application), uiImplementation: UIImplementation = CustomTabsUIImplementation(), isSsoEnabled: Boolean = false, preAuthenticatedURLEnabled: Boolean = false, name: String? = null, app2AppOptions: App2AppOptions = App2AppOptions(isEnabled = false))

Constructors

Link copied to clipboard
constructor(application: Application, clientId: String, authgearEndpoint: String, tokenStorage: TokenStorage = PersistentTokenStorage(application), uiImplementation: UIImplementation = CustomTabsUIImplementation(), isSsoEnabled: Boolean = false, preAuthenticatedURLEnabled: Boolean = false, name: String? = null, app2AppOptions: App2AppOptions = App2AppOptions(isEnabled = false))

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Current access token.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

OAuth client ID.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Current session state. See SessionState.

Functions

Link copied to clipboard

Approve a app2app authentication request.

Link copied to clipboard
fun authenticate(options: AuthenticateOptions, onAuthenticateListener: OnAuthenticateListener, handler: Handler = Handler(Looper.getMainLooper()))

Authenticate a user by directing the user to an external browser to authenticate.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun authenticateAnonymously(onAuthenticateAnonymouslyListener: OnAuthenticateAnonymouslyListener, handler: Handler = Handler(Looper.getMainLooper()))

Authenticate anonymously by generating a dummy user. The dummy user persist until the app is uninstalled.

Link copied to clipboard
fun authenticateBiometric(options: BiometricOptions, onAuthenticateBiometricListener: OnAuthenticateBiometricListener, handler: Handler = Handler(Looper.getMainLooper()))

Authenticate with previously enabled biometric.

Link copied to clipboard
Link copied to clipboard
fun changePassword(options: SettingsActionOptions, listener: OnOpenSettingsActionListener? = null, handler: Handler = Handler(Looper.getMainLooper()))

Open change password page in webview

Link copied to clipboard
fun checkBiometricSupported(context: Context, allowedAuthenticators: Int)

Check if biometric is supported. If not supported, an exception will be thrown.

Link copied to clipboard

Clear SDK session state. Clear refresh token and reset session state to SessionState.NO_SESSION.

Link copied to clipboard
fun configure(onConfigureListener: OnConfigureListener, handler: Handler = Handler(Looper.getMainLooper()))

Configure authgear. This must be ran before any other methods. If configuration is successful and there was a valid user session, authgear's accessToken is non-null and the token is ready to be used.

Link copied to clipboard
suspend fun Authgear.configure()
Link copied to clipboard
fun createAuthenticateRequest(options: AuthenticateOptions, listener: OnCreateAuthenticationRequestListener, handler: Handler = Handler(Looper.getMainLooper()))
Link copied to clipboard
fun deleteAccount(options: SettingsActionOptions, listener: OnOpenSettingsActionListener? = null, handler: Handler = Handler(Looper.getMainLooper()))

Open delete account page in webview

Link copied to clipboard

Disable biometric if it was enabled.

Link copied to clipboard
fun enableBiometric(options: BiometricOptions, onEnableBiometricListener: OnEnableBiometricListener, handler: Handler = Handler(Looper.getMainLooper()))

Enable biometric for the current user.

Link copied to clipboard
@RequiresApi(value = 23)
suspend fun Authgear.enableBiometric(options: BiometricOptions)
Link copied to clipboard
fun fetchUserInfo(onFetchUserInfoListener: OnFetchUserInfoListener, handler: Handler = Handler(Looper.getMainLooper()))

Fetch user info. Note that this method does not refresh access token so user should call configure or refreshAccessTokenIfNeeded when necessary.

Link copied to clipboard
Link copied to clipboard
fun finishAuthentication(finishUri: String, request: AuthenticationRequest, listener: OnAuthenticateListener, handler: Handler = Handler(Looper.getMainLooper()))
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun generateUrl(redirectURI: String, listener: OnGenerateURLListener, handler: Handler = Handler(Looper.getMainLooper()))

Generate URL for opening webpage with current session.

Link copied to clipboard
suspend fun Authgear.generateUrl(redirectURI: String): Uri
Link copied to clipboard

Check if biometric is enabled.

Link copied to clipboard
fun logout(force: Boolean? = null, onLogoutListener: OnLogoutListener, handler: Handler = Handler(Looper.getMainLooper()))

Logout the current session by revoking the refresh token and access token. It works for both normal user and anonymous user. For both cases, you can obtain the session again via authenticate or authenticateAnonymously.

Link copied to clipboard
suspend fun Authgear.logout(force: Boolean? = null)
Link copied to clipboard
fun makePreAuthenticatedURL(options: PreAuthenticatedURLOptions, listener: OnMakePreAuthenticatedURLListener, handler: Handler = Handler(Looper.getMainLooper()))

Share the current authenticated session to a web browser. preAuthenticatedURLEnabled must be set to true to use this method.

Link copied to clipboard
fun open(page: Page, options: SettingOptions? = null, listener: OnOpenURLListener? = null, handler: Handler = Handler(Looper.getMainLooper()))

Open the specific Page in web view.

Link copied to clipboard
fun openUrl(path: String, listener: OnOpenURLListener? = null, handler: Handler = Handler(Looper.getMainLooper()))

Open the specific path on the authgear server.

Link copied to clipboard

Parse an uri into app2app authentication request.

Link copied to clipboard
fun promoteAnonymousUser(options: PromoteOptions, onPromoteAnonymousUserListener: OnPromoteAnonymousUserListener, handler: Handler = Handler(Looper.getMainLooper()))

Promote the current anonymous user. Note that this must not be called before there is an anonymous user.

Link copied to clipboard
Link copied to clipboard
fun reauthenticate(options: ReauthenticateOptions, biometricOptions: BiometricOptions?, listener: OnReauthenticateListener, handler: Handler = Handler(Looper.getMainLooper()))

Reauthenticate the user either by biometric or web.

Link copied to clipboard
fun refreshAccessTokenIfNeeded(onRefreshAccessTokenIfNeededListener: OnRefreshAccessTokenIfNeededListener, handler: Handler = Handler(Looper.getMainLooper()))

Refresh access token when necessary.

Link copied to clipboard

Refresh access token when necessary synchronously if needed. Do NOT call this on the main thread.

Link copied to clipboard
fun refreshIDToken(listener: OnRefreshIDTokenListener, handler: Handler = Handler(Looper.getMainLooper()))

Refresh ID token.

Link copied to clipboard
Link copied to clipboard

Reject a app2app authentication request.

Link copied to clipboard
fun startApp2AppAuthentication(options: App2AppAuthenticateOptions, onAuthenticateListener: OnAuthenticateListener, handler: Handler = Handler(Looper.getMainLooper()))

Start app2app authentication.

Link copied to clipboard
fun wechatAuthCallback(code: String, state: String, onWechatAuthCallbackListener: OnWechatAuthCallbackListener, handler: Handler = Handler(Looper.getMainLooper()))

WeChat auth callback function. In WeChat login flow, after returning from the WeChat SDK, this function should be called to complete the authorization.