Back to Home
Authentication
Secure authentication is crucial for protecting your account and ensuring the integrity of the RUE API. This guide explains the authentication methods supported by our API and how to implement them in your applications.
API Key Authentication
The primary method of authentication for the RUE API is via API keys. Each request to the API must include your API key to be authenticated.
Obtaining an API Key
- Log in to your RUE API account on our developer portal
- Navigate to the "API Keys" section
- Click "Generate New API Key"
- Copy and securely store your new API key
Using Your API Key
Include your API key in the X-API-Key
header of each request:
curl -X POST https://api.rue.ai/v1/scrape_metadata \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_API_KEY" \
-d '{"url": "https://example.com"}'
OAuth 2.0 Authentication
For applications that require more advanced authentication flows, we also support OAuth 2.0. This allows you to authenticate on behalf of users and access their data securely.
OAuth 2.0 Flow
- Register your application in the RUE API developer portal
- Obtain your client ID and client secret
- Implement the OAuth 2.0 authorization code flow in your application
- Exchange the authorization code for an access token
- Use the access token to make authenticated API requests
Example OAuth 2.0 Flow
const axios = require('axios');
const querystring = require('querystring');
// Step 1: Redirect user to authorization URL
const authorizationUrl = 'https://api.rue.ai/oauth/authorize?' +
querystring.stringify({
client_id: 'YOUR_CLIENT_ID',
redirect_uri: 'YOUR_REDIRECT_URI',
response_type: 'code',
scope: 'read write'
});
// Step 2: Exchange authorization code for access token
async function getAccessToken(authorizationCode) {
const response = await axios.post('https://api.rue.ai/oauth/token', {
grant_type: 'authorization_code',
code: authorizationCode,
redirect_uri: 'YOUR_REDIRECT_URI',
client_id: 'YOUR_CLIENT_ID',
client_secret: 'YOUR_CLIENT_SECRET'
});
return response.data.access_token;
}
// Step 3: Use access token for API requests
async function makeApiRequest(accessToken) {
const response = await axios.get('https://api.rue.ai/v1/user_data', {
headers: { 'Authorization': `Bearer ${accessToken}` }
});
return response.data;
}
Best Practices for Authentication
- Never share your API keys or client secrets
- Rotate your API keys periodically
- Use environment variables to store sensitive credentials
- Implement proper error handling for authentication failures
- Use HTTPS for all API requests to ensure data security
Troubleshooting Authentication Issues
If you encounter authentication problems, check the following:
- Ensure your API key or access token is valid and not expired
- Check that you're using the correct authentication method for the endpoint
- Verify that your OAuth 2.0 redirect URI is correctly configured
- Review our Error Handling guide for specific error messages
For any persistent authentication issues, please contact our support team for assistance.