Technical Resources & Tutorials
Integrations, functional examples, and reusable snippets for your projects with FACEIT, Steam, and more.
Authentication using PKCE verifier. Requires your Client ID and developer registration.
File: index.php
<?php
session_start();
$clientId = "your_client_id";
$redirectUri = "https://yoursite.com/";
?>
<a href="/auth/faceit_login.php">FACEIT Login</a>
File: faceit_login.php
<?php
session_start();
function generatePkceCodeVerifier() {
return bin2hex(random_bytes(32));
}
function generatePkceCodeChallenge($verifier) {
return rtrim(strtr(base64_encode(hash('sha256', $verifier, true)), '+/', '-_'), '=');
}
$clientId = "your_client_id";
$codeVerifier = generatePkceCodeVerifier();
$_SESSION['pkce_code_verifier'] = $codeVerifier;
$codeChallenge = generatePkceCodeChallenge($codeVerifier);
$authUrl = "https://accounts.faceit.com/accounts?redirect_popup=true"
. "&response_type=code"
. "&client_id=" . urlencode($clientId)
. "&code_challenge=" . urlencode($codeChallenge)
. "&code_challenge_method=S256"
. "&redirect_uri=" . urlencode("https://yoursite.com/auth/faceit_callback.php");
header("Location: $authUrl");
exit();
File: faceit_callback.php
<?php
session_start();
$code = $_GET['code'] ?? null;
$codeVerifier = $_SESSION['pkce_code_verifier'] ?? null;
$clientId = "your_client_id";
$clientSecret = "xxxxx";
$redirectUri = "https://yoursite.com/auth/faceit_callback.php";
$tokenEndpoint = "https://api.faceit.com/auth/v1/oauth/token";
$postFields = http_build_query([
'grant_type' => 'authorization_code',
'code' => $code,
'redirect_uri' => $redirectUri,
'code_verifier' => $codeVerifier,
'client_id' => $clientId
]);
$authHeader = "Authorization: Basic " . base64_encode("$clientId:$clientSecret");
$ch = curl_init($tokenEndpoint);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [$authHeader, 'Content-Type: application/x-www-form-urlencoded']);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
$response = curl_exec($ch);
curl_close($ch);
$tokenInfo = json_decode($response, true);
if (isset($tokenInfo['access_token'])) {
// Save data or continue flow
}
Coming soon: Steam user login.
Coming soon: FACEIT stats from the API.
Coming soon: using Steam Web API to fetch data.