Search docs/
Native SolutionsCore Device

Auth Connect


Ionic Auth Connect handles logging in and/or registering a user with an authentication provider (such as Auth0, Azure AD, or AWS Cognito) using industry standard OAuth/OpenId Connect on iOS, Android, or on the web.

When used with Ionic Identity Vault, it provides a complete security solution for authentication and storage of logged-in credentials.

Auth Connect also allows your app to support multiple authentication providers. Should you need to change providers, easily switch between them without having to develop a new solution. Learn more.

Update the native project config files:

// Android - AndroidManifest.xml
    <data android:scheme="$AUTH_URL_SCHEME"/>
    <action android:name="android.intent.action.VIEW"/>
    <category android:name="android.intent.category.DEFAULT"/>
    <category android:name="android.intent.category.BROWSABLE"/>
    <action android:name="android.intent.action.SEND"/>
    <category android:name="android.intent.category.DEFAULT"/>
    <data android:mimeType="text/*"/>

// iOS - Info.plist (inside existing CFBundleURLTypes)

Reference App

A complete login/logout experience using Auth0. Simply swap the Auth0 configuration in the IonicAuthOptions object to switch to a different auth provider.

Configuring Auth Connect

The hosting app configures Auth Connect with settings specific to each authentication provider. This is done by passing in an instance of IonicAuthOptions to the IIonicAuth class. The IIonicAuth class is the main interface exposed by the Auth Connect plugin, and is expected to be subclassed for specific behaviors and/or events.

The default behavior for caching tokens in the plugin is not secure and should be replaced with something more robust, such as integrating it with the Ionic Identity Vault.

To access callbacks, and override behavior as needed, it is recommended to subclass the IIonicAuth interface.

Supported Providers

Leveraging the OAuth/OpenId Connect protocols, Auth Connect supports:


The typical Auth Connect workflow consists of:

  1. The hosting app instantiates the Auth Connect Plugin, passing in the IonicAuthOptions object. Configure it based on the chosen auth provider.
  2. On app load, the hosting app calls IsAuthenticated to check if the user is logged in already.
  3. If the user isn't logged in, redirect the app to a Login page and call the Login method. Auth Connect loads the chosen auth provider's login page.
  4. The app user enters their username and password and taps the provider's login button.
  5. On success, Auth Connect automatically retrieves and stores the user's access token. The onLoginSuccess method is fired, and the app can redirect to the desired protected homepage.
  6. The IsAuthenticated method can be called at any point to refresh the access token.
  7. Use GetAccessToken to retrieve the access token if making any API requests to the auth provider.

Web Configuration Options

Login UX Options

Login can occur either within the current tab/window or a separate pop-up window (the default). Here's a visual comparison:

The current tab option is great for developers supporting IE11. Within the IonicAuthOptions configuration, set implicit_login to "CURRENT". Next, in the login page (or whichever page is navigated to after login - the redirectUri in the config options) implement:

async ngOnInit() {
  // If coming back after logging into the auth provider,
  // grab the token from the URL and pass it to Auth Connect
  if (window.location.hash) {
    // Pass it to Auth Connect
    await this.authentication.handleCallback(window.location.href);
    // Navigate to another page

Testing Locally

To test an Ionic app using Auth Connect locally, configure IonicAuthOptions to use http://localhost:8100/ as the base URL for properties such as redirectUri and logoutUrl. Then, run the ionic serve command.

Upgrade from v1.1.1 to >=v1.1.2

Important Note

If you're upgrading from version 1.1.1 to >=1.1.2, there are fewer dependencies required to install with the plugin. Simply run the commands below to upgrade. Imports and usage should remain identical.

NOTE: {your url scheme} is the app specific url schemes the plugin was installed with.

First, remove v1.1.1 of the plugin:

ionic cordova plugin rm @ionic-enterprise/auth --variable AUTH_URL_SCHEME={your url scheme}

You should make sure @ionic-enterprise/auth and cordova-plugin-advanced-http are completely removed from your package.json in all locations.

  "dependencies": {
     // Make sure both these are gone from the dependencies
    "@ionic-enterprise/auth": "1.1.1",
    "cordova-plugin-advanced-http": "^2.0.9",
  "cordova": {
    "plugins": {
      // Make sure both these are gone from the cordova plugins section as well
      "@ionic-enterprise/auth": {},
      "cordova-plugin-advanced-http": {}

It should now be safe to add >=v1.1.2 of the plugin:

ionic cordova plugin add @ionic-enterprise/auth@latest --variable AUTH_URL_SCHEME={your url scheme}

API Documentation

You can find the API and interface documentation for everything below. The main classes to pay attention to are:








onLoginSuccess(result: AuthResult): void


Name Type
result AuthResult

Returns: void


onLogout(): void

Returns: void




additionalLoginParameters(parameters: object): void


Name Type Description
parameters object any additional parameters that should be added to the login request examples: `login_hint`, `domain_hint`

Returns: void


expire(): Promise<void>

expire the current access token, but keep the refresh token, useful for testing

Returns: Promise<void>


getAccessToken(tokenName?: undefined | string, scopes?: undefined | string): Promise<string | undefined>

get the access token, once logged in, for API calls


Name Type
Optional tokenName undefined | string
Optional scopes undefined | string

Returns: Promise<string | undefined>


getAuthResponse(): Promise<any | undefined>

get the full original auth response

Returns: Promise<any | undefined>


getIdToken(): Promise<IDTokenType | undefined>

get the parsed id token, includes requested scope values

Returns: Promise<IDTokenType | undefined>


handleCallback(url: string): Promise<AuthResult>

called by the hosting app when callbacks happen, these will be to the URL specified in the options for LogoutUrl and RedirectUri


Name Type Description
url string callback url to handle

Returns: Promise<AuthResult>


isAuthenticated(): Promise<boolean>

check to see if the user is logged in, and refresh the token if needed

Returns: Promise<boolean>


login(overrideUrl?: undefined | string): Promise<void>

Using configuration display the auth provider's login UI.

The overrideUrl parameter should only be used when the default discovery url needs to be overrode. (The known use case is with Azure AD custom user flows/policies.)


Name Type
Optional overrideUrl undefined | string

Returns: Promise<void>


logout(): Promise<void>

log the user out

Returns: Promise<void>


onLoginSuccess(response: any): void

Event handler which can be overridden to handle successful login events


Name Type
response any

Returns: void


onLogout(): void

Event handler which can be overridden to handle successful logout events

Returns: void




● isPasscodeSetupNeeded: boolean




getVault(): Promise<VaultInterface>

Returns: Promise<VaultInterface>


setPasscode(): Promise<void>

Returns: Promise<void>



Provided by the hosting app, this interface allows the hosting app to configure, and provide information needed to login, logout.

<Optional> androidToolbarColor

● androidToolbarColor: undefined | string

setting to allow the toolbar color of the android webview control to be set. Takes a string that can be parsed as a color by

<Optional> audience

● audience: undefined | string

Provided audience (aud) value

<Optional> authConfig

● authConfig: *"auth0" | "azure" | "cognito"*

The type of the Auth Server, currently only the following are supported:

  • Auth0
  • Azure Active Directory
  • Cognito (AWS)


● clientID: string

Provided Application ID

<Optional> clientSecret

● clientSecret: undefined | string

The client secret, optional only required for Cognito/Web

<Optional> discoveryUrl

● discoveryUrl: undefined | string

Location of the Auth Server's discovery endpoint, can be null for Azure

<Optional> implicitLogin

● implicitLogin: *"CURRENT" | "POPUP"*

for implicit login (aka web) should the auth window be opened in a new popup window/tab or the current windwow/tab defaults to: POPUP for CURRENT to work the app will need to call IIonicAuth::handleCallback when the auth service navigates to the url set in redirect_url

<Optional> iosWebView

● iosWebView: *"private" | "shared"*

setting the option to shared allows for sharing a session between Safari and other applications for a true SSO experience between apps but on iOS 11 and higher it will prompt the user for permission to share the website data with the application. Using private avoids the prompt but the session will only be shared with Safari on iOS 10 or lower.

<Optional> logLevel

● logLevel: *"DEBUG" | "ERROR" | "NONE"*

The log level for the module


● logoutUrl: string

Location that the hosting app expects logout callbacks to navigate to.

<Optional> platform

● platform: *"web" | "cordova" | "capacitor"*

Are we hosted in cordova, web, capacitor

<Optional> redirectUri

● redirectUri: undefined | string

Location that the hosting app expects callbacks to navigate to.

<Optional> scope

● scope: undefined | string

User details requested from the Authentication provider, each provider may support standard {e.g. openid, profile, email, etc.}, or custom scopes.

<Optional> tokenStorageProvider

● tokenStorageProvider: *"localStorage" | TokenStorageProvider | IVUserInterface*

The type of storage to use for the tokens



This interface can be implemented by the hosting app, and set in the options it should be a wrapper around access to a secure storage solution if Ionic Identity Vault is not being used.

<Optional> clear

● clear: undefined | function

clear storage

<Optional> getAccessToken

● getAccessToken: undefined | function

get the saved access token

<Optional> getAuthResponse

● getAuthResponse: undefined | function

get the full auth result

<Optional> getIdToken

● getIdToken: undefined | function

get the id token

<Optional> getRefreshToken

● getRefreshToken: undefined | function

get the saved refresh token

<Optional> setAccessToken

● setAccessToken: undefined | function

save the access token

<Optional> setAuthResponse

● setAuthResponse: undefined | function

save the full auth response

<Optional> setIdToken

● setIdToken: undefined | function

save the id token

<Optional> setRefreshToken

● setRefreshToken: undefined | function

save the refresh token




clear(): Promise<void>

Returns: Promise<void>


getConfig(): Promise<IVConfig>

Returns: Promise<IVConfig>


getValue(name: string): Promise<any>


Name Type
name string

Returns: Promise<any>


storeValue(name: string, value: any): Promise<any>


Name Type
name string
value any

Returns: Promise<any>


<Const> ready

● ready: Promise<unknown> = new Promise(resolve => { document.addEventListener('deviceready', () => { resolve(); }); })


[1.3.5] (2019-12-17)

Bug Fixes

  • ios: prevent blank screen on SFSafariViewController presentation

[1.3.4] (2019-12-04)

Bug Fixes

  • android: implement IonicSecureWebView.hide() to avoid invalid action
  • ios: add in new interface for ios 13 when using ASWebAuthenticationPresentationContextProviding

[1.3.3] (2019-11-08)

Bug Fixes

  • ios: rename AFNetworking symbols that conflic with advanced-http plugin

[1.3.2] (2019-11-01)

[1.3.1] (2019-10-29)

[1.3.0] (2019-10-09)

Bug Fixes

  • make sure interfaces are not snake cased, move some parameters off to method to make them more dynmaic, clean up some parameter checking to be more clear, make some dictionary combines clearer.


  • ios,android,web: changes for supporting implicit path (aka web) in window rather than in tabs. allow pass through of login_hint value for azure/auth0 and domain_hint for azure. fixes for param handling

[1.2.0] (2019-09-16)

Bug Fixes

  • all: remove unneeded plugin deps
  • ios, web, android: make sure the access token is valid before returning it
  • web: password reset error was being ignored and needed to check (hash) not (query params) for value
  • Web: Fix issue with IE 11 not working.


  • ios,android,web: support acquiring multiple tokens from an oauth source (especially azure ad), also fix some issues with refresh for the web path. The major change is that getToken now has two optional paramters, they both must be passed in or neither. The parameters are an id for the token being acquired and the specific scope for the token being acquired.

[1.1.4] (2019-08-28)

[1.1.3] (2019-08-21)

[1.1.2] (2019-08-14)

[1.1.1] (2019-07-29)

Bug Fixes

  • Android, iOS: fix incorrect package.json dependency

[1.1.0] (2019-07-29)


  • iOS, Android: Remove extra plugin dependencies and unify flow across Android and all iOS webviews.

Other Versions