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 (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 local.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
signInRedirectUri=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/asfor available authorization servers.clientId- is your applications client id, created in your okta admin dashboardsignInRedirectUri- is used for external identity providers, and should follow the format of reverse domain name notation +:/login, ie:com.okta.sample.android:/login
You can open this sample in Android Studio or build it using gradle.
./gradlew :dynamic-app:assembleDebug./gradlew :dynamic-app:connectedCheckAdd 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
socialEmail: example-change-me
socialPassword: example-change-me
socialName: example-change-me
socialEmailMfa: example-change-me
socialPasswordMfa: example-change-me
socialNameMfa: example-change-me
managementSdk:
clientId: example-change-me
orgUrl: example-change-me
token: example-change-me
a18n:
token: example-change-meRun the cucumber tests from the command line.
./gradlew :dynamic-app:connectedCheck -PcucumberUseAndroidJUnitRunner=false