Get Started?
Before you can use our service, at least you have to create an 1Akun app.
1. Login
- Click "Get Started" button on top of this page.
- Follow the step until you manage to see the dashboard.
2. 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.
- Done.
Integration
Before you can integrate your app with our system, 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
auth_user_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://app.1akun.com/api/client/exchange' \ -H 'X-App-ID: your-app-id' \ -H 'X-App-Secret: your-app-secret' \ -H 'Content-Type: application/json' \ --data-raw '{"code": "the_auth_code_goes_here"}'
4. 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 Onboaring Link then put it into your button. See example below.
https://app.1akun.com/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 whereauth_user_id
= "user-1234". - If it doesn't exist, then create a user with
auth_user_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.