First, check if there’s an existing Basic SDK for your technology stack and use it instead for a better dev experience!
Summary
There are two main steps to integrating Basic into your app: implement Basic Auth, then call the database APIs with the user’s access token.Auth APIs guide
Implement signup / login flows for your app’s users
Database APIs guide
Write and display data safely in your app
Basic Auth APIs guide
Basic uses OAuth 2.0 for authentication. For more details, read about Basic Auth. In this guide, you will:- Use “redirect to sign in” endpoint to redirect users to account creation / login flow
- Extract code from URL
- Use “get auth token” endpoint with extracted code
- Store auth token object for future API calls
Use "redirect to sign in" endpoint
Create a button that redirects the user to the Basic Auth page, with the following required parameters (more info on required parameters):
client_id='YOUR_CLIENT_ID'redirect_uri='YOUR_REDIRECT_URI'response_type=codescope=profilestate='YOUR_STATE'
https://api.basic.tech/auth/authorize?response_type=code&redirect_uri=YOUR_REDIRECT_URI&scope=profile&state=YOUR_STATE&client_id=YOUR_CLIENT_IDReplace
YOUR_CLIENT_ID, YOUR_REDIRECT_URI, and YOUR_STATE with your own values. scope must be a space-separated list (for example profile alone, or profile plus datastore scopes your app needs). The live contract matches the OpenAPI spec (GET /auth/authorize).PKCE (recommended): You may include
code_challenge and code_challenge_method=S256 on the authorize request and the matching code_verifier when exchanging the code at /auth/token. See Basic Auth for the full OAuth flow.Extract code from URL
The authorization code will be in the URL as a
code query parameter.
For example:
https://your-app.com/callback?code=1234567890.You need to extract the code from the URL and use it in the next step.Use "get auth token" endpoint with extracted code
Make a post request to
/auth/token with the authorization code in the body. The response will be a JSON object with the access token and a refresh code.Token URL template:
https://api.basic.tech/auth/tokenMake sure to replace
YOUR_CODE with your own valuesBasic database APIs guide
The database APIs are easy to use. Make sure to check the validity of theaccess_token, and pass it in the Header of your API call.
If the access_token is expired, you’d repeat step 3 of the Auth APIs guide but using the refresh_token instead of the extracted code. This will return you a fresh new access_token.
Here’s how to validate and use the access token in different programming languages:

