Authentication
This guide explains how to authenticate with the PinkCloudSync API.
Overview
PinkCloudSync uses a two-step authentication process1:
- Obtain an access token using your API key and secret
- Use the token to authenticate all subsequent API requests
sequenceDiagram
participant Client
participant API
Client->>API: POST /auth/token<br/>(api_key, api_secret)
API->>Client: access_token (JWT)
Client->>API: GET /sync/sessions<br/>(Authorization: Bearer token)
API->>Client: Response data
Prerequisites
Before you begin, make sure you have:
- An active PinkCloudSync account
- API key and secret (obtain from the console)
- Basic knowledge of REST APIs
- An installed tool for working with APIs (curl, Postman, or Python)
Step 1: Obtain Access Token
To get an access token, send a POST request to the /auth/token endpoint with your API credentials.
Request
1 2 3 4 5 6 | |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | |
Response
1 2 3 4 5 | |
Response Fields
| Field | Type | Description |
|---|---|---|
access_token |
string | JWT token for authentication |
token_type |
string | Always "Bearer" |
expires_in |
integer | Token lifetime in seconds (3600 = 1 hour) |
Token Expiration
Access tokens expire after 1 hour. You'll need to request a new token when the current one expires.
Step 2: Use the Token
Include the access token in the Authorization header of all API requests.
Header Format
1 | |
Example Request
1 2 | |
1 2 3 4 5 6 7 8 9 10 11 12 | |
Token Management
Storing Tokens
Store access tokens securely:
- Never commit tokens to version control
- Use environment variables or secure vaults
- Encrypt tokens at rest if storing in a database
1 2 3 4 5 6 7 8 | |
1 2 | |
Token Refresh
Implement automatic token refresh to handle expiration:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
Error Handling
Common Authentication Errors
401 Unauthorized
Cause: Invalid API credentials or expired token
Solution: * Verify your API key and secret * Request a new token if expired * Check for typos in credentials
1 2 3 4 | |
403 Forbidden
Cause: Valid credentials but insufficient permissions
Solution: * Check your API key permissions in the console * Ensure the key has the required scopes
1 2 3 4 | |
Handling Errors in Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | |
Security Best Practices
API Key Management
- Rotate keys regularly — create new keys every 90 days
- Use separate keys — different keys for development and production
- Limit permissions — grant only necessary permissions to each key
- Monitor usage — review API key usage logs regularly
Token Security
- Never log tokens — avoid logging access tokens in application logs
- Use HTTPS only — always use HTTPS for API requests
- Implement timeouts — set reasonable timeouts for API requests
- Handle errors gracefully — don't expose tokens in error messages
Security Warning
Never share your API secret or access tokens. Treat them like passwords.
API Key Permissions
Each API key can have the following permissions:
| Permission | Description |
|---|---|
sync:read |
Read sync session information |
sync:write |
Create and manage sync sessions |
conflicts:read |
View conflicts |
conflicts:write |
Resolve conflicts |
admin |
Full access to all resources |
Checking Permissions
You can check your current permissions by decoding the JWT token:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | |
Next Steps
- Data Synchronization — create your first sync session
- Conflict Resolution — handle data conflicts
-
The access token is a JWT (JSON Web Token) that contains encoded information about the user and their permissions. ↩