Before integrating Auth Connect into your Ionic app, you’ll need to get AWS Cognito up and running.
For complete information on configuring AWS Cognito, consult the official documentation which includes tutorials on creating user and identity pools and more.
When creating a User Pool, be sure to add an app client. Additional Auth Connect-related configurations can be found under the App integration and Federation sections.
Run the following command to install the Auth Connect plugin. For the
AUTH_URL_SCHEME variable, use the globally unique App Id (ex:
com.company.app) you decided on when configuring the Azure AD app above.
If you have not already setup Ionic Enterprise in your app, follow the one-time setup steps.
Next, install the plugin:
It's recommended to create an
AuthenticationService class that encapsulates AWS Cognito and Ionic Auth Connect’s login functionality.
Generate this class using the
ionic generate command:
IonicAuth class, then configure all AWS Cognito details in the
Some of these
IonicAuthOptions values are unique, and must be set based on your Cognito details:
platform: Use “cordova” or “capacitor” accordingly.
clientID: Your app’s Client ID, found under [User Pool] -> General Settings -> App clients.
clientSecret: Your apps' Client Secret, found under [User Pool] -> General Settings -> App clients.
redirectUri: The URI to redirect to after the user has logged in. Use the same AUTH_URL_SCHEME variable value (App Id) from when the Auth Connect plugin was installed. Example: com.company.app://callback. Find this under [User Pool] -> App Integration -> App client settings.
logoutUrl: The URI to redirect to after the user has logged out. Example: com.company.app://login?logout=true. Find this under [User Pool] -> App Integration -> App client settings.
discoveryUrl formula is:
REGION is the hosted AWS region (like "us-east-1) and
USER-POOL-ID is the Pool Id (like "us-east-1_vdkald21"), found under [User Pool] -> General Settings.