Authorization Flow Implementation
Complete guide to implementing the authorization process
Authorization Flow
Authorization is the first critical step in the integration process. This flow creates a secure connection between your game, the player, and our platform.
Process Overview
- Your game initiates an authorization request
- The player authenticates through our platform
- Your game polls for completion status
- Upon successful authorization, you receive a token for subsequent API calls
Step 1: Initiate Authorization
POST /api/games/auth/initiate
This endpoint creates an authorization request and returns the necessary information to complete the process.
Request Parameters
Parameter | Type | Required | Description |
---|---|---|---|
game_uuid | string | Yes | Your game's unique identifier (use test UUID during development) |
device_uuid | string | No | A persistent device identifier that remains consistent across installations |
Example Request
{
"game_uuid": "404e1b2b-de1b-4988-8cc8-94239dc482b3",
"device_uuid": "550e8400-e29b-41d4-a716-446655440000"
}
Response Structure
Field | Type | Description |
---|---|---|
auth_id | string | Unique identifier for this authorization request (store this value) |
auth_url | string | URL to direct the player to for authentication |
Example Response
{
"auth_id": "d63d00da-ed78-4eba-b531-0f556e64cd4e",
"auth_url": "https://app.playmanity.net/auth/games/authorize/d63d00da-ed78-4eba-b531-0f556e64cd4e"
}
Step 2: Poll for Authorization Status
Once you've initiated the authorization request and directed the player to the auth_url
, you need to poll our API to check when the player completes the process.
POST /api/games/auth/status/[auth_id]
Poll this endpoint to check the authorization status and retrieve the auth token when available.
Request Parameters
Parameter | Type | Required | Description |
---|---|---|---|
auth_id | string | Yes | The authorization ID received from the initiate endpoint |
Response Structure
Field | Type | Description |
---|---|---|
status | string | Current status: "valid", "denied", or "unresolved" |
auth_token | string | (Only present when status is "valid") The authorization token for future API calls |
game | string | Internal game ID used by our platform |
Example Response (Success)
{
"status": "valid",
"auth_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"game": "123"
}
Example Response (Pending)
{
"status": "unresolved",
"game": "123"
}
Best Practices
-
Polling Frequency: Poll the status endpoint every 1-2 seconds. Polling too frequently may impact performance.
-
Token Storage: Securely store the
auth_token
for the duration of the game session. -
Error Handling: Implement proper timeout and retry logic for cases where authorization takes longer than expected.
-
User Experience: Provide clear feedback to the player during the authorization process.
Next Steps
After successful authorization, you'll need to establish a game session before requesting advertisements. See the Session Management section for details.