This repository contains a sample Android application which can be used a reference for using Okta IDX Java on Android.
❕ This Sample Application uses an SDK that requires usage of the Okta Identity Engine. This functionality is in General Availability but is being gradually rolled out to customers. If you want to gain access to the Okta Identity Engine, please reach out to your account manager. If you do not have an account manager, please reach out to [email protected] for more information.
This Sample Application will show you the best practices for integrating Authentication into your app using Okta's Identity Engine. Specifically, this application will cover some basic needed use cases to get you up and running quickly with Okta. These Examples are:
- Sign In
- Sign Out
- Sign Up
- Sign In/Sign Up with Social Identity Providers
- Sign In with Multifactor Authentication using Email or Phone
- Password reset using Email
If you run into problems using the SDK, you can
- Ask questions on the Okta Developer Forums
- Post issues here on GitHub (for code errors)
Before running this sample, you will need the following:
- An Okta Developer Account, you can sign up for one at https://developer.okta.com/signup/.
- An Okta Application, configured for Mobile app.
-
After login, from the Admin dashboard, navigate to Applications→Add Application
-
Choose Native as the platform
-
Populate your new Native OpenID Connect application with values similar to:
Setting Value Application Name MyApp (must be unique) Sign-in redirect URIs com.okta.sample.android:/login Allowed grant types Authorization Code, Interaction Code, Refresh Token (recommended) -
Click Finish to redirect back to the General Settings of your application.
-
Copy the Client ID, as it will be needed for the client configuration.
-
Get your issuer, which is a combination of your Org URL (found in the upper right of the console home page) . For example, https://dev-1234.okta.com.
-
Ensure your authorization server has enabled the Interaction Code flow. Navigate to Security -> API -> Authorization Servers -> default -> Access Policies -> Default Policy -> Edit Default Policy Rule -> Interaction Code -> Update Rule
-
Note: As with any Okta application, make sure you assign Users or Groups to the application. Otherwise, no one can use it.
Open the project in Android Studio
Update the okta.properties
file in the projects root directory with
the contents created from the okta admin dashboard:
issuer=https://YOUR_ORG.okta.com/oauth2/default
clientId=test-client-id
redirectUri=com.okta.sample.android:/login
Notes:
issuer
- is your authorization server, usuallyhttps://your_okta_domain.okta.com/oauth2/default
, but custom authorization servers are supported. Seehttps://your_okta_domain.okta.com/admin/oauth2/as
for available authorization servers.clientId
- is your applications client id, created in your okta admin dashboardredirectUri
- is used for external identity providers, and should follow the format of reverse domain name notation +/login
, ie:com.okta.sample.android:/login
This sample uses Okta IDX Java Library dependency in build.gradle
file:
implementation "com.okta.idx.sdk:okta-idx-java-api:${okta.sdk.version}"
See the latest release here.
You can open this sample in Android Studio or build it using gradle.
./gradlew :app:assembleDebug
./gradlew connectedCheck
Add a file called e2eCredentials.yaml
to app/src/androidTest/resources
directory.
Supply contents to the yaml file:
cucumber:
username: example-change-me
password: example-change-me
invalidUsername: example-change-me
invalidPassword: example-change-me
firstName: example-change-me
newPassword: example-change-me
facebookEmail: example-change-me
facebookPassword: example-change-me
facebookName: example-change-me
facebookEmailMfa: example-change-me
facebookPasswordMfa: example-change-me
facebookNameMfa: example-change-me
managementSdk:
clientId: example-change-me
orgUrl: example-change-me
token: example-change-me
a18n:
token: example-change-me
Run the cucumber tests from the command line.
./gradlew connectedCheck -PcucumberUseAndroidJUnitRunner=false
We are happy to accept contributions and PRs! Please see the contribution guide to understand how to structure a contribution.