Quickstart
Begin is the most elegant way to build Functional Web Apps. The Begin API gives developers complete control over every aspect of the Begin platform.
- Register a
client_id
- Issue an
access_token
- Install an API client for Node or Deno
Node
Bash
npm i @begin/api
JavaScript
import { App } from '@begin/api'
Deno
JavaScript
import { App } from 'https://api.begin.com/deno/begin@latest/mod.ts'
Authentication
The Begin API implements oAuth 2.0 Device Flow.
Device Flow Overview
- Your app requests device and user verification codes and gets the authorization URL where the user will authenticate with Begin.
- The user authenticates.
- The app polls for the user authentication status. Once the user has authorized, the app will be able to make API calls with a new
access_token
.
Step 1: App requests the device_code
Your app requests a user code and verification URL that the app will display to the end user to authenticate in the next step. This request also returns a devicer_ code
that the app will use to receive an access_ token
.
Request
POST /devicecode
Host: api.begin.com
Content-Type: application/x-www-form-urlencoded
client_id=xxx
Body Parameters
Name | Type | Description |
client_id |
string |
Required. The client ID is registered to your app. |
All responses are application/json
.
Response
{
"device_code": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"user_code": "XXXXXXXX",
"verification_uri": "https://api.begin.com/auth"
}
Name | Type | Description |
device_code |
string |
The device verification code is used to request an access_token . |
user_code |
string |
The user code identifies the user authenticating. |
verification_uri |
string |
The verification URL for user authenticating. |
Step 2: Prompt the user to authenticate
Your device will show the user verification code and prompt the user to enter the code at https://api.begin.com/auth?user_code=XXXXXXXX
.
Step 3: App polls to check if the user authenticated
Your app will make device authorization requests that poll POST https://api.begin.com/token
, until the device and user codes expire or the user has successfully authorized.
Request
POST /token
Host: api.begin.com
Content-Type: application/x-www-form-urlencoded
client_id=xxx&device_code=xxx
Body Parameters
Name | Type | Description |
client_id |
string |
Required. The client ID is registered to your app. |
device_code |
string |
Required. The device_code you received from POST https://api.begin.com/devicecode request. |
Response
{
"access_token": "xxx",
}
Name | Type | Description |
access_token |
string |
Use the access_token to make authenticated API requests. |