I'm working on a website that need a steam connexion i'm using OpenId and everything works fine on localhost. but since it's been put on a domain it wont work. it gives me just " error " as you can see on the picture linked.Here is the image
I put my code as well down bellow
<?php
$login_url_params = [
'openid.ns' => 'http://specs.openid.net/auth/2.0',
'openid.mode' => 'checkid_setup',
'openid.return_to' => 'http://localhost/projet_v3/login_system/process-openId.php',
'openid.realm' => (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'],
'openid.identity' => 'http://specs.openid.net/auth/2.0/identifier_select',
'openid.claimed_id' => 'http://specs.openid.net/auth/2.0/identifier_select',
];
$steam_login_url = 'https://steamcommunity.com/openid/login' . '?' . http_build_query($login_url_params, '', '&');
header("location: $steam_login_url;");
exit();
?>
<?php
session_start();
function p($arr)
{
return '<pre>' . print_r($arr, true) . '</pre>';
}
$params = [
'openid.assoc_handle' => $_GET['openid_assoc_handle'],
'openid.signed' => $_GET['openid_signed'],
'openid.sig' => $_GET['openid_sig'],
'openid.ns' => 'http://specs.openid.net/auth/2.0',
'openid.mode' => 'check_authentication',
];
$signed = explode(',', $_GET['openid_signed']);
foreach ($signed as $item) {
$val = $_GET['openid_' . str_replace('.', '_', $item)];
$params['openid.' . $item] = stripslashes($val);
}
$data = http_build_query($params);
//data prep
$context = stream_context_create([
'http' => [
'method' => 'POST',
'header' => "Accept-language: en\r\n" .
"Content-type: application/x-www-form-urlencoded\r\n" .
'Content-Length: ' . strlen($data) . "\r\n",
'content' => $data,
],
]);
//get the data
$result = file_get_contents('https://steamcommunity.com/openid/login', false, $context);
if (preg_match("#is_valid\s*:\s*true#i", $result)) {
preg_match('#^https://steamcommunity.com/openid/id/([0-9]{17,25})#', $_GET['openid_claimed_id'], $matches);
$steamID64 = is_numeric($matches[1]) ? $matches[1] : 0;
echo 'request has been validated by open id, returning the client id (steam id) of: ' . $steamID64;
} else {
echo 'error: unable to validate your request';
exit();
}
$steam_api_key = 'C80CB5DD858414479B410D77840EBF46';
$response = file_get_contents('https://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=' . $steam_api_key . '&steamids=' . $steamID64);
$response = json_decode($response, true);
$userData = $response['response']['players'][0];
$_SESSION['logged_in'] = true;
$_SESSION['userData'] = [
'steam_id' => $userData['steamid'],
'profile_url' => $userData['profileurl'],
'name' => $userData['personaname'],
'avatar' => $userData['avatarmedium'],
];
$_SESSION['theme-color'] = false;
$redirect_url = "../includes/steamInfosHandler.php";
header("Location: $redirect_url");
exit();
I've seen some things about SameSite=None problem but I can't figure out what this is and to resolve it.