API Authentication
Learn how to authenticate with the RefineAI API to securely access our code optimization services programmatically.
Authentication Methods
RefineAI API supports two authentication methods:
API Key Authentication
The simplest method for authenticating with the RefineAI API. Suitable for most use cases.
Example HTTP request with API key:
curl -X POST https://api.refine-ai.tech/v1/analyze \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"repository": "https://github.com/username/repo"}'
OAuth 2.0
For applications that need to access RefineAI on behalf of users. Provides more granular permission control.
OAuth 2.0 authorization flow:
// 1. Redirect user to authorization URL https://auth.refine-ai.tech/oauth/authorize? client_id=YOUR_CLIENT_ID& redirect_uri=YOUR_REDIRECT_URI& response_type=code& scope=analyze optimize
Obtaining API Keys
To obtain an API key for RefineAI, follow these steps:
- 1Log in to your RefineAI account at dashboard.refine-ai.tech
- 2Navigate to the "API Keys" section in your account settings
- 3Click "Create New API Key" and provide a name for your key
- 4Select the appropriate permissions for your use case
- 5Copy your API key and store it securely - you won't be able to view it again
API Key Security
Your API keys carry many privileges, so it's important to keep them secure:
Best Practices
- •Never hardcode API keys directly in your source code
- •Use environment variables or secure vaults to store API keys
- •Don't expose API keys in client-side JavaScript
- •Rotate API keys periodically and after team member departures
- •Use different API keys for development and production environments
Security Warning
Never share your API keys publicly or commit them to version control systems. If you believe your API key has been compromised, revoke it immediately from your dashboard and generate a new one.