Developer Guide

Get Started?

Before you can use our service, at least you have an account in Kunber.

1. Login

  1. Click "Login/Register" button on top of this page.
  2. Follow the step until you manage to see the dashboard.

2. Activate Developer Mode

  1. Go to My Account, click "Update" button.
  2. Select profile, fill the form.
  3. Update Developer Mode field to On. Then Save Changes

3. Create App

  1. Click menu (top right), go to "My App".
  2. Click "Create New" button, and fill the form.
  3. Once you hit "Save" button, your app will be listed on the page.

Integration

Before you can integrate your app with our service, you need to prepare your app.

1. Prepare your frontend

  1. Create a login button (can be in Login page or anywhere else).
  2. If user click the button, it will redirect to the Onboarding Link

2. Prepare your DB

  1. Add a column to your users table in your DB called kunber_id, string (36 chars).

3. Prepare your backend

  1. Create a page or just GET endpoint (Callback URL) (e.g https://yourapp.com/authorize).
  2. If any request come, you need to get the auth_code from query string.
  3. Do http request to our system (Exchange Token). See CURL below.
  4. Get the user information from the response (UserData). Then you can use it to authenticate the user.
CURL -L -X POST 'https://kunber.zone.id/api/client/exchange' \
  -H 'Authorization: Basic your-basic-auth-here' \
  -H 'Content-Type: application/json' \
  --data-raw '{"code": "the_auth_code_goes_here"}'
  1. Basic auth is formed by your app-id as the user and app-secret as the password. Then encode it in base64.
// PHP
base64_encode($app_id . ':' . $app_secret)
// Node js
Buffer.from(app_id + ':' + app_secret).toString('base64')

Create Onboarding Link

  1. Go to "My App" again, now click the app name and see your app detail.
  2. Click "Edit" button, add your Callback URL, then Save.
  3. Create your Onboarding Link then put it into your button. See example below.
https://kunber.zone.id/onboarding/your-app-id?callback_url=https://yourapp.com/authorize

Authenticate User

After you get the UserData, now you need to authenticate your user.

1. Find or Create User

  1. Get the id from UserData (e.g. user-1234) then query to your DB. Find the user where kunber_id = "user-1234".
  2. If it doesn't exist, then create a user with kunber_id = "user-1234". You may also save all of information from UserData to your users table.
  3. Now, you have the user (e.g. John).

2. Login

  • If your app is using JWT, then generate the JWT for John.
  • If you use a stateful web framework (e.g. Laravel, AdonisJS, etc), you can just login with the id of John.
  • If your app is using cookie, then just generate the cookie for John.
Last updated: 2024-07-26
Kunber

Kunber is one of PT. Geksa non-profit projects.

We developed this service to make developing software easier. Especially in the authentication parts.