Get Started?
Before you can use our service, at least you have an account in Kunber.
1. Login
- Click "Login/Register" button on top of this page.
- Follow the step until you manage to see the dashboard.
2. Activate Developer Mode
- Go to My Account, click "Update" button.
- Select profile, fill the form.
- Update Developer Mode field to On. Then Save Changes
3. Create App
- Click menu (top right), go to "My App".
- Click "Create New" button, and fill the form.
- 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
- Create a login button (can be in Login page or anywhere else).
- If user click the button, it will redirect to the Onboarding Link
2. Prepare your DB
- Add a column to your users table in your DB called
kunber_id
, string (36 chars).
3. Prepare your backend
- Create a page or just GET endpoint (Callback URL) (e.g https://yourapp.com/authorize).
- If any request come, you need to get the auth_code from query string.
- Do http request to our system (Exchange Token). See CURL below.
- 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"}'
- 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
- Go to "My App" again, now click the app name and see your app detail.
- Click "Edit" button, add your Callback URL, then Save.
- 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
- Get the id from UserData (e.g. user-1234) then query to your DB. Find the user where
kunber_id
= "user-1234". - 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. - 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.