The Kinde Android SDK allows developers to quickly and securely integrate a new or existing application to the Kinde platform.

You can also view the docs in the GitHub repo.

Register for Kinde

Link to this section

If you haven’t already got a Kinde account, register for free here (no credit card required).

You also need a Kinde domain to get started, e.g. yourapp.kinde.com

KindeSDK is available through Maven. To install it, simply add the following line to your build.gradle:

...

implementation 'com.kinde:android-sdk:<version>'

...

You should also include Retrofit and the GSON converter as dependencies:

...

implementation "com.squareup.retrofit2:retrofit:<version>"

implementation "com.squareup.retrofit2:converter-gson:<version>"

...

Configure Kinde

Link to this section

Set callback URLs

Link to this section
  1. In Kinde, go to Settings > Applications.

  2. View the application details. This is where you get app keys and set the callback URLs.

  3. Add your callback URLs in the relevant fields. For example:

    • Allowed callback URLs: {your_url_scheme}://<your_kinde_host>//kinde_callback - for example myapp://myhost.kinde.com//kinde_callback

    • Allowed logout redirect URLs: {your_url_scheme}://<your_kinde_host>//kinde_logoutcallback - for example myapp://myhost.kinde.com//kinde_logoutcallback

  4. Select Save.

Add environments

Link to this section

If you would like to use our Environments feature as part of your development process. You will need to create them within your Kinde account. In this case you would use the Environment subdomain in the code block above.

Configure your app

Link to this section

Environment variables

Link to this section

The SDK reads configuration from meta-data, so you should add meta-data to <application> section of your AndroidManifest.xml.

You can find these variables on your Kinde Settings -> App keys page.

  • au.kinde.domain: your Kinde domain
  • au.kinde.clientId - you can find this on the App Keys page
...
<application ...>
...
	<meta-data
		android:name="au.kinde.domain"
		android:value="your_kinde_url" />

	<meta-data
		android:name="au.kinde.clientId"
		android:value="your_kinde_client_id" />
...
</application>
...

Configuration example:

...
<application ...>
...
	<meta-data
		android:name="au.kinde.domain"
		android:value="app.kinde.com" />

	<meta-data
		android:name="au.kinde.clientId"
		android:value="test@live" />
...
</application>
...

Integrate with your app

Link to this section

You’ll need to import the SDK package in your android app.

...
import android.os.Handler
import android.util.Log
...

class YourActivity : AppCompatActivity() {

...
private lateinit var sdk: KindeSDK
...

override fun onCreate(savedInstanceState: Bundle?) {
...
	sdk = KindeSDK(this, object : KindeSDK.SDKListener {

		override fun onNewToken(token: String) {
			// Need to implement
		}

		override fun onLogout() {
			// Need to implement
		}

		override fun onException(exception: Exception) {
			Handler(Looper.getMainLooper()).post {
				Log.e("MyActivity", "Something wrong init KindeSDK: " + exception.message)
			}
		}
	})
...
}

Login / Register

Link to this section

The Kinde client provides methods for a simple login / register flow. Add buttons in your view as follows:

...
findViewById<View>(R.id.b_sign_in).setOnClickListener {
	sdk.login(GrantType.PKCE)
}

findViewById<View>(R.id.b_sign_up).setOnClickListener {
	sdk.register(GrantType.PKCE)
}
...

Handle redirect

Link to this section

Once your user is redirected back to your site from Kinde (it means you’ve logged in successfully), you need to implement the onNewToken function from the SDK.

sdk = KindeSDK(this, object : KindeSDK.SDKListener {
	override fun onNewToken(token: String) {
	// Need to implement
	}
...
}

This is implemented in much the same way as logging in or registering. The Kinde SPA client comes with a logout method.

findViewById<View>(R.id.b_sign_out).setOnClickListener {
	sdk.logout()
}

Get user information

Link to this section

To access the user information, call the getUser method

sdk.getUser()?.let {
	Handler(Looper.getMainLooper()).post {
	Log.i("MyActivity", it.firstName + " " + it.lastName)
	}
}

View users in Kinde

Link to this section

In Kinde, go to Users to view all users and subscribers.

User Permissions

Link to this section

Once a user has been verified, your application will be returned the JWT token with an array of permissions for that user. You will need to configure your application to read permissions and unlock the respective functions.

Set roles and permissions at the Business level in Kinde. Here’s an example of permissions.

String[] permissions = {
	“create:todos”,
	“update:todos”,
	“read:todos”,
	“delete:todos”,
	“create:tasks”,
	“update:tasks”,
	“read:tasks”,
	“delete:tasks”,
}

If you need any assistance with getting Kinde connected, reach out to us at support@kinde.com.

Talk to us

If you can’t find what you’re looking for in our help center — email our team

Contact us
Talk to us