Learn how to authenticate with the OnlyOneAPI platform securely
Primary authentication method
API keys are the primary method of authentication for OnlyOneAPI. Each key is unique to your account and should be kept secure.
// Include your API key in the Authorization header
const response = await fetch('https://api.onlyoneapi.com/v1/endpoint', {
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
}
});
For user-delegated access
For applications that need to access OnlyOneAPI on behalf of users, we support OAuth2 authentication flow.
// 1. Redirect user to authorization URL
const authUrl = 'https://auth.onlyoneapi.com/oauth/authorize?' +
'client_id=YOUR_CLIENT_ID&' +
'redirect_uri=YOUR_REDIRECT_URI&' +
'response_type=code&' +
'scope=read write';
// 2. Exchange authorization code for access token
const tokenResponse = await fetch('https://auth.onlyoneapi.com/oauth/token', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
grant_type: 'authorization_code',
code: authorizationCode,
client_id: YOUR_CLIENT_ID,
client_secret: YOUR_CLIENT_SECRET
})
});
Keep your API secure
Always keep API keys on your server
Store keys in .env files, never in code
Generate new keys every 90 days
Restrict API access to known IPs
Now that you understand authentication, start building with our APIs.