Skip to content

chrisdmills-okta/okta-idx-android

 
 

Repository files navigation

License

Okta IDX Android - embedded-auth-with-sdk

This repository contains a sample Android application which can be used a reference for using Okta IDX Java on Android.

Introduction

❕ 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 oie@okta.com 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:

  1. Sign In
  2. Sign Out
  3. Sign Up
  4. Sign In/Sign Up with Social Identity Providers
  5. Sign In with Multifactor Authentication using Email or Phone
  6. Password reset using Email

Need help?

If you run into problems using the SDK, you can

Installation & Running The App

Prerequisites

Okta Admin Dashboard

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.
    1. After login, from the Admin dashboard, navigate to ApplicationsAdd Application

    2. Choose Native as the platform

    3. 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)
    4. Click Finish to redirect back to the General Settings of your application.

    5. Copy the Client ID, as it will be needed for the client configuration.

    6. 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.

    7. 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.

Android Studio

Open the project in Android Studio

Configuration

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, usually https://your_okta_domain.okta.com/oauth2/default, but custom authorization servers are supported. See https://your_okta_domain.okta.com/admin/oauth2/as for available authorization servers.
  • clientId - is your applications client id, created in your okta admin dashboard
  • redirectUri - is used for external identity providers, and should follow the format of reverse domain name notation + /login, ie: com.okta.sample.android:/login

Dependencies

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.

Running This Sample

You can open this sample in Android Studio or build it using gradle.

./gradlew :app:assembleDebug

Running tests with mock data

./gradlew connectedCheck

Running end to end tests

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

Contributing

We are happy to accept contributions and PRs! Please see the contribution guide to understand how to structure a contribution.

Releases

No releases published

Packages

No packages published

Languages

  • Kotlin 94.2%
  • Gherkin 4.9%
  • Other 0.9%