API Authentication Guide
Authentication Methodsβ
I Hate PPT API supports multiple authentication methods to ensure secure and reliable API calls.
π Try I Hate PPT API NowAPI Key Authenticationβ
Getting API Keysβ
- Log in to I Hate PPT Console
- Navigate to "API Management" page
- Click "Create API Key"
- Enter key name and description
- Select permission scope
- Copy the generated key
Using API Keysβ
curl -X POST https://api.ihateppt.com/v1/ppt/generate \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"topic": "AI Development Trends"}'
Permission Scopesβ
read- Read-only permissions, can query datawrite- Read-write permissions, can create and modify dataadmin- Administrator permissions, can manage all resources
OAuth 2.0 Authenticationβ
Authorization Flowβ
- Authorization Request - Redirect user to authorization page
- User Authorization - User confirms authorization on the page
- Get Authorization Code - System returns authorization code
- Exchange Token - Use authorization code to get access token
- API Call - Use access token to call API
Authorization URLβ
https://api.ihateppt.com/oauth/authorize?
client_id=YOUR_CLIENT_ID&
redirect_uri=YOUR_REDIRECT_URI&
response_type=code&
scope=read write&
state=random_state_string
Get Access Tokenβ
curl -X POST https://api.ihateppt.com/oauth/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=authorization_code&
code=AUTHORIZATION_CODE&
redirect_uri=YOUR_REDIRECT_URI&
client_id=YOUR_CLIENT_ID&
client_secret=YOUR_CLIENT_SECRET"
Using Access Tokenβ
curl -X POST https://api.ihateppt.com/v1/ppt/generate \
-H "Authorization: Bearer ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"topic": "AI Development Trends"}'
JWT Token Authenticationβ
Getting JWT Tokenβ
curl -X POST https://api.ihateppt.com/auth/login \
-H "Content-Type: application/json" \
-d '{
"username": "your_username",
"password": "your_password"
}'
Response Exampleβ
{
"success": true,
"data": {
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"expires_in": 3600,
"token_type": "Bearer"
}
}
Refresh Tokenβ
curl -X POST https://api.ihateppt.com/auth/refresh \
-H "Content-Type: application/json" \
-d '{
"refresh_token": "your_refresh_token"
}'
Signature Authenticationβ
Calculate Signatureβ
import hmac
import hashlib
import time
import base64
def generate_signature(method, url, body, secret):
# Build signature string
timestamp = str(int(time.time()))
message = f"{method}\n{url}\n{body}\n{timestamp}"
# Calculate HMAC-SHA256 signature
signature = hmac.new(
secret.encode('utf-8'),
message.encode('utf-8'),
hashlib.sha256
).digest()
# Base64 encode
return base64.b64encode(signature).decode('utf-8')
Ready to integrate with your app?
Get started with our powerful API and SDK. Build amazing presentation features into your own applications.
View API DocsUsing Signatureβ
curl -X POST https://api.ihateppt.com/v1/ppt/generate \
-H "Authorization: Signature YOUR_SIGNATURE" \
-H "X-Timestamp: 1640995200" \
-H "Content-Type: application/json" \
-d '{"topic": "AI Development Trends"}'
Multi-Factor Authenticationβ
Enable MFAβ
- Go to "Security Settings" in the console
- Select "Multi-Factor Authentication"
- Scan QR code or enter secret key
- Enter verification code to complete setup
Using MFAβ
curl -X POST https://api.ihateppt.com/v1/ppt/generate \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "X-MFA-Token: 123456" \
-H "Content-Type: application/json" \
-d '{"topic": "AI Development Trends"}'
Permission Managementβ
Role Permissionsβ
- Owner - Has all permissions
- Admin - Administrative permissions, can manage users and resources
- Editor - Edit permissions, can create and modify PPTs
- Viewer - View permissions, can only view PPTs
Resource Permissionsβ
- PPT Management - Create, edit, delete PPTs
- File Management - Upload, download, delete files
- User Management - Manage user accounts and permissions
- API Management - Manage API keys and access permissions
Permission Checkβ
def check_permission(user, resource, action):
# Check if user has permission to perform action
if user.role == 'owner':
return True
if resource == 'ppt' and action == 'create':
return user.role in ['owner', 'admin', 'editor']
if resource == 'user' and action == 'manage':
return user.role in ['owner', 'admin']
return False
Security Best Practicesβ
API Key Securityβ
- Protect Keys - Don't hardcode API keys in code
- Environment Variables - Use environment variables to store keys
- Regular Rotation - Regularly rotate API keys
- Minimal Permissions - Only grant necessary permissions
Network Securityβ
- Use HTTPS - Always use HTTPS for API calls
- IP Whitelist - Limit API access by IP address
- Request Signing - Use request signing to prevent tampering
- Rate Limiting - Implement rate limiting to prevent abuse
Monitoring and Auditingβ
- Access Logs - Log all API access
- Anomaly Detection - Monitor unusual access patterns
- Regular Audits - Regularly audit permissions and access records
- Alert Mechanism - Set up security event alerts
Error Handlingβ
Authentication Errorsβ
{
"success": false,
"error": {
"code": "AUTHENTICATION_FAILED",
"message": "Authentication failed",
"details": {
"reason": "invalid_token",
"expires_at": "2024-01-15T10:30:00Z"
}
}
}
Permission Errorsβ
{
"success": false,
"error": {
"code": "INSUFFICIENT_PERMISSIONS",
"message": "Insufficient permissions",
"details": {
"required_permission": "ppt:create",
"user_permissions": ["ppt:read"]
}
}
}
Frequently Asked Questionsβ
Q: What to do if API key is compromised?β
A:
- Immediately revoke the compromised key in the console
- Generate a new API key
- Check for unauthorized API calls
- Update all applications using that key
Q: How to improve API security?β
A:
- Use HTTPS for all API calls
- Implement IP whitelist restrictions
- Enable multi-factor authentication
- Regularly rotate API keys
Q: How to handle token expiration?β
A:
- Implement automatic token refresh mechanism
- Proactively refresh tokens before expiration
- Handle refresh failure scenarios
- Provide user-friendly error messages
Q: How to monitor API usage?β
A:
- View API usage statistics
- Set up usage alerts
- Monitor unusual access patterns
- Regularly review access logs
Ready to integrate with your app?
Get started with our powerful API and SDK. Build amazing presentation features into your own applications.
View API DocsGet Started with API - Check out API Reference for detailed API interface documentation.