⚒️Game Integration Setup Guide
Objective: To enable users to connect their game accounts to Ludo Rewards, access their rewards, and integrate with Discord.
Step 1: User Login
Action: Implement a 'Login to Ludo Rewards' button in your game's user interface.
Process: When this button is clicked, initiate an HTTP GET request to the Ludo Rewards login endpoint with the player's unique ID and customer ID.
Parameters:
playerId
(Player's unique ID)customerId
(Player's unique customer ID from Ludo)
Example Endpoint:
https://{ludorewards_url}/api/v1/auth?playerId=12345&customerId=67890
Expected Response: The response will include
session_token
,discord_user_id
andplayer_id
which is used for further authentication.
Sample Code:
document.getElementById('loginButton').addEventListener('click', function() {
const playerId = '12345'; // Replace with actual player ID
const customerId = '67890'; // Replace with actual customer ID from Ludo
const url = `https://{ludorewards_url}/api/v1/login?playerId=${playerId}&customerId=${customerId}`;
fetch(url)
.then(response => response.json())
.then(data => {
// Store sessionToken from data for further requests
const sessionToken = data.session_token;
// Handle successful login
})
.catch(error => {
// Handle errors
});
});
Step 2: Checking Login Status
Action: After logging in, call the
/me
endpoint to confirm the user's login status.Headers: Include the received
session_token
in the request headers for secure authentication.Expected Response: The response includes
playerId
andid
, the Ludo user ID.
Sample Code:
const sessionId = 'YOUR_SESSION_TOKEN'; // Replace with the session token from login
fetch('https://{ludo_url}/api/v1/auth/me', {
headers: { Authorization: `Bearer ${sessionId}` }
})
.then(response => response.json())
.then(data => {
// Handle successful user data retrieval
})
.catch(error => {
// Handle errors
});
Step 3: Logging Out
Action: Implement a logout functionality.
Process: Call the
/logout
endpoint with the user'ssession_token
to log the user out.Headers: Include the
session_token
in the request headers.
Sample Code:
javascriptCopy code// JavaScript code for logging out
const sessionId = 'YOUR_SESSION_TOKEN'; // Replace with the session token from login
fetch('https://{ludo_url}/api/v1/logout', {
headers: { Authorization: `Bearer ${sessionId}` },
method: 'POST'
})
.then(response => {
// Handle successful logout
})
.catch(error => {
// Handle errors
});
Additional Steps:
Storing User Data: Securely store the received
session_token
,playerId
, andludoUserId
in your game's database.Error Handling: Implement error handling to manage scenarios where the connection process fails.
Displaying Rewards and Discord Integration: Provide options in your game's UI for users to view their rewards and check their Discord integration status.
Note: Ensure that the provided URLs, endpoints, and parameter names align with your specific implementation. Test thoroughly to ensure a smooth user experience.
Last updated