Authentication overview

Dangerous Discord Database provides programmatic access to its features, such as querying user reports and submitting new moderation actions, through a RESTful API. Secure access to these API endpoints requires authentication to verify the identity of the requesting application or user. The platform supports industry-standard authentication mechanisms designed to protect data integrity and user privacy. All API communication with Dangerous Discord Database must occur over HTTPS/TLS to encrypt data in transit, preventing eavesdropping and tampering of requests and responses Dangerous Discord Database security practices.

The choice of authentication method depends on the integration type:

  • API Keys: Ideal for server-to-server communication where an application needs direct access to its own Dangerous Discord Database resources without user interaction.
  • OAuth 2.0: Suitable for applications that need to access Dangerous Discord Database resources on behalf of a user, requiring the user's explicit consent.

Developers are expected to manage their credentials securely and adhere to best practices for API key storage and OAuth token handling to prevent unauthorized access Dangerous Discord Database API access guide.

Supported authentication methods

Dangerous Discord Database supports two primary authentication methods for its API, each designed for specific use cases and security requirements.

Method When to Use Security Level
API Keys Server-side applications, background services, direct scripts. When an application accesses its own data. High (if securely stored and transmitted via HTTPS).
OAuth 2.0 Web applications, mobile apps. When an application needs to act on behalf of a user with their consent. High (delegated access, short-lived tokens, refresh tokens).

API Keys

API keys are unique, secret tokens used to authenticate an application. When an API key is included in a request, Dangerous Discord Database uses it to identify the application making the call and to verify its authorization to access the requested resources. API keys are typically long, randomly generated strings that should be treated as sensitive credentials, similar to passwords Dangerous Discord Database API key management.

For Dangerous Discord Database, API keys are passed in the Authorization header using the Bearer scheme:

Authorization: Bearer YOUR_API_KEY

It is crucial to protect API keys from unauthorized access. Exposure of an API key could lead to unauthorized use of your Dangerous Discord Database account and potential data breaches.

OAuth 2.0

OAuth 2.0 is an authorization framework that enables an application to obtain limited access to a user's Dangerous Discord Database account without exposing the user's credentials. It is commonly used for third-party applications that integrate with Dangerous Discord Database and require user-specific permissions, such as allowing a community management tool to ban users on behalf of a moderator OAuth 2.0 specification overview.

Dangerous Discord Database implements the OAuth 2.0 Authorization Code Grant type, which is suitable for web applications. The general flow involves:

  1. The client application redirects the user to Dangerous Discord Database's authorization server.
  2. The user logs in to Dangerous Discord Database (if not already logged in) and grants permission to the client application.
  3. Dangerous Discord Database redirects the user back to the client application with an authorization code.
  4. The client application exchanges the authorization code for an access token and optionally a refresh token by making a server-side request to Dangerous Discord Database's token endpoint.
  5. The client application uses the access token to make authenticated API requests on behalf of the user.

Access tokens are typically short-lived, enhancing security by limiting the window of opportunity for misuse if intercepted. Refresh tokens, if issued, allow the client application to obtain new access tokens without requiring the user to re-authorize Dangerous Discord Database OAuth integration guide.

Getting your credentials

To interact with the Dangerous Discord Database API, you need to obtain the appropriate credentials from your developer dashboard. The process differs slightly for API keys and OAuth 2.0 client credentials.

Obtaining API Keys

  1. Log in to the Developer Dashboard: Navigate to the Dangerous Discord Database developer dashboard and log in with your account credentials.
  2. Access API Key Management: Locate the 'API Keys' or 'Developer Settings' section within the dashboard.
  3. Generate a New API Key: Click on the 'Generate New API Key' button. You may be prompted to provide a name or description for the key to help you manage multiple keys for different applications.
  4. Securely Store the Key: Once generated, the API key will be displayed. Copy it immediately and store it in a secure location. For security reasons, the key will typically only be shown once and cannot be retrieved later Generating Dangerous Discord Database API keys.
  5. Configure Permissions (Optional): Some platforms allow you to configure specific permissions or scopes for your API keys. Review and adjust these settings as needed to follow the principle of least privilege.

It is recommended to generate separate API keys for different applications or environments (e.g., development, staging, production) to simplify key rotation and revocation.

Obtaining OAuth 2.0 Client Credentials

For OAuth 2.0, you need to register your application with Dangerous Discord Database to obtain a Client ID and Client Secret.

  1. Register Your Application: In the Dangerous Discord Database developer dashboard, navigate to the 'Applications' or 'OAuth Clients' section.
  2. Create a New Application: Click 'Create New Application'. You will need to provide details such as your application's name, description, and crucially, the authorized redirect URIs (callback URLs). These are the URLs to which Dangerous Discord Database will redirect the user after authorization.
  3. Obtain Client ID and Client Secret: Upon successful registration, you will be issued a Client ID and a Client Secret. The Client ID is public and identifies your application. The Client Secret is confidential and should be kept secure, similar to an API key.
  4. Configure Scopes: Define the necessary OAuth scopes that your application will request access to, such as moderation.read or users.ban. These scopes determine the specific permissions your application will have on behalf of the user.

The Client Secret should never be exposed in client-side code (e.g., JavaScript in a browser) and must only be used in secure server-side environments.

Authenticated request example

This example demonstrates how to make an authenticated request to a hypothetical Dangerous Discord Database endpoint using an API key. For OAuth 2.0, the process is similar, but you would use an access token obtained through the OAuth flow instead of a static API key.

Using an API Key

Let's assume you want to retrieve a list of recent user reports from the /reports endpoint. You would include your API key in the Authorization header.

Python Example (using requests library)

import requests
import os

# It's best practice to store API keys in environment variables
API_KEY = os.environ.get("DANGEROUS_DISCORD_DATABASE_API_KEY")
BASE_URL = "https://api.dangerousdiscorddatabase.com/v1"

if not API_KEY:
    raise ValueError("DANGEROUS_DISCORD_DATABASE_API_KEY environment variable not set.")

headers = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json"
}

try:
    response = requests.get(f"{BASE_URL}/reports", headers=headers)
    response.raise_for_status() # Raise an exception for HTTP errors (4xx or 5xx)

    reports = response.json()
    print("Successfully retrieved reports:")
    for report in reports["data"]:
        print(f"  Report ID: {report['id']}, User: {report['user_id']}, Reason: {report['reason']}")

except requests.exceptions.HTTPError as err:
    print(f"HTTP error occurred: {err}")
    print(f"Response body: {err.response.text}")
except requests.exceptions.RequestException as err:
    print(f"An error occurred: {err}")

cURL Example

curl -X GET \
  'https://api.dangerousdiscorddatabase.com/v1/reports' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json'

Replace YOUR_API_KEY with your actual API key. For production environments, always retrieve API keys from secure environment variables or a secret management service, rather than hardcoding them AWS Secrets Manager documentation.

Security best practices

Implementing robust security practices is essential when integrating with the Dangerous Discord Database API to protect your application, user data, and maintain the integrity of the platform. Adhering to these guidelines helps mitigate common security risks.

API Key Management

  • Store Keys Securely: Never hardcode API keys directly into your application's source code. Use environment variables, secret management services (e.g., AWS Secrets Manager, Google Secret Manager), or secure configuration files that are not committed to version control Google Secret Manager overview.
  • Restrict Permissions: If the platform allows, configure API keys with the minimum necessary permissions (least privilege) required for your application's functionality.
  • Rotate Keys Regularly: Periodically generate new API keys and revoke old ones. This limits the impact if a key is compromised.
  • Monitor Usage: Keep an eye on API usage logs for unusual activity that might indicate a compromised key.
  • Avoid Client-Side Exposure: Never expose API keys in client-side code (e.g., JavaScript in web browsers, mobile app binaries) where they can be easily extracted. All API calls requiring a secret key should be proxied through your secure backend server.

OAuth 2.0 Implementation

  • Protect Client Secret: Treat your OAuth Client Secret with the same level of security as an API key. It must only be used on your secure server-side.
  • Validate Redirect URIs: Ensure that you register and strictly validate all redirect URIs in your Dangerous Discord Database application settings. This prevents authorization codes from being sent to malicious endpoints.
  • Use PKCE (Proof Key for Code Exchange): For public clients (mobile and single-page applications), implement PKCE to mitigate authorization code interception attacks. Dangerous Discord Database recommends PKCE for enhanced security Dangerous Discord Database PKCE implementation.
  • Securely Store Tokens: Access tokens and refresh tokens should be stored securely. For web applications, access tokens can be held in memory or secure, HTTP-only cookies. Refresh tokens, being long-lived, require even greater protection, often encrypted and stored in a secure database.
  • Implement State Parameter: Use the state parameter during the OAuth authorization flow to prevent Cross-Site Request Forgery (CSRF) attacks. The state parameter should be a unique, unguessable value generated by your application for each authorization request and validated upon callback.
  • Check Token Expiration: Always check the expiration time of access tokens and handle token refresh gracefully using refresh tokens if available.

General Security Practices

  • Always Use HTTPS/TLS: All communication with the Dangerous Discord Database API must be encrypted using HTTPS/TLS. This protects credentials and data from interception during transit.
  • Input Validation: Validate all input sent to the API to prevent injection attacks and ensure data integrity.
  • Error Handling: Implement robust error handling to gracefully manage API errors without exposing sensitive information in error messages.
  • Rate Limiting: Be aware of and respect Dangerous Discord Database's API rate limits to prevent your application from being temporarily blocked. Implement retry logic with exponential backoff for rate-limited responses.
  • Regular Security Audits: Periodically review your application's authentication and authorization mechanisms for potential vulnerabilities.