Sign In through Steam not working (OpenID)

2.2k Views Asked by At

Alright, I am having a bit of a problem with signing in through steam on my website. The code seems to work up until you press the "Yes, sign in." here: Screenshot.

When I click the "Yes, sign in." button it redirects me back to the page that the sign in button was on and the sign in button is not not visible as if it worked but the scripted logout button is not there either. It is just a blank page and it has a really long URL:

http://localhost/Websites/Unknown%20Infernos/?page=login&login&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.mode=id_res&openid.op_endpoint=https%3A%2F%2Fsteamcommunity.com%2Fopenid%2Flogin&openid.claimed_id=http%3A%2F%2Fsteamcommunity.com%2Fopenid%2Fid%2F76561198059756738&openid.identity=http%3A%2F%2Fsteamcommunity.com%2Fopenid%2Fid%2F76561198059756738&openid.return_to=http%3A%2F%2Flocalhost%2FWebsites%2FUnknown%2520Infernos%2F%3Fpage%3Dlogin%26login&openid.response_nonce=2014-01-24T10%3A00%3A27Ze43wSImRFeCb5vc9qw8uwlv8y9c%3D&openid.assoc_handle=1234567890&openid.signed=signed%2Cop_endpoint%2Cclaimed_id%2Cidentity%2Creturn_to%2Cresponse_nonce%2Cassoc_handle&openid.sig=SYWQBh%2BxowKdUqWvVhK6nl7Vskk%3D

The log in button also comes back after a page refresh.

Here is the code, I am using the LightOpenID API.

<?php
session_start();

include "openid.php";

$key = "XXXXXXXXXXXXXXXXXXXXXXXXX";
$OpenID = new LightOpenID("localhost");

if (!$OpenID->mode) {

    if (isset($_GET['login'])) {
        $OpenID->identity = "http://steamcommunity.com/openid";
        header("Location: {$OpenID->authUrl()}");
    }

    if (!isset($_SESSION['T2SteamAuth'])) {
        $login = "<div id=\"login\">Welcome Guest. Please <a href=\"?login\"><img src=\"http://cdn.steamcommunity.com/public/images/signinthroughsteam/sits_small.png\"/></a> to access this website.</div>";
    } elseif ($OpenID->mode == "cancel") {
        echo "user has cancelled Authentication.";
    } else {

        if (!isset($_SESSION['T2SteamAuth'])) {

            $_SESSION['T2SteamAuth'] = $OpenID->validate() ? $OpenID->identity : null;
            $_SESSION['T2SteamID64'] = str_replace("http://steamcommunity.com/openid/id", "", $_SESSION['T2SteamAuth']);

            if ($_SESSION['T2SteamAuth'] !== null) {

                $Steam64 = str_replace("http://steamcommunity.com/openid/id", "", $_SESSION['T2SteamAuth']);
                $profile = file_get_contents("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key={$key}&steamids={$Steam64}");
                $buffer = fopen("cache/{$Steam64}.json", "w+");
                fwrite($buffer, $profile);
                fclose($buffer);

            }

            header("Location: ./index.php")

        }

    }

    if (isset($_SESSION['T2SteamAuth'])) {

        $login = "<div id=\"login\">Welcome Guest. Please <a href=\"?logout\">Logout</a> to access this website.</div>";

    }

    if (isset($_GET['logout'])) {

        unset($_SESSION['T2SteamAuth']);
        unset($_SESSION['T2SteamID64']);
        header("Location: ./index.php");

    }

    $steam = json_decode(file_get_contents("cache/{$_SESSION['T2SteamID64']}.json"));

    echo $login;

    //echo "<img src\"{$steam->responce->players[0]->avatarfull}\"/>";

}

?>
0

There are 0 best solutions below