SmItH197 / SteamAuthentication

A simple PHP Authentication that enables steam users to log into their steam account to access content!
MIT License
446 stars 144 forks source link

loginbutton() Issue. #253

Open Flinty916 opened 5 years ago

Flinty916 commented 5 years ago

Hi.

I have been working with steamauth on localhost for a while. I recently moved it to a new domain, and with a new API key etc. However, now my login page does not work.

Details; Pressing the login button redirects to ?login however, does not redirect to the steam site to login.

Login page: ` <?php if(!isset($_SESSION['steamid'])) {

            echo "welcome guest! please login<br><br>";
            loginbutton(); //login button

        }  else {
            include ('steamauth/userInfo.php');

            //Protected content
            echo "Welcome back " . $steamprofile['personaname'] . "</br>";
            echo "here is your avatar: </br>" . '<img src="'.$steamprofile['avatarfull'].'" title="" alt="" /><br>'; // Display their avatar!

            logoutbutton();
        }    
        ?>  `

I have changed nothing in the steamauth folder, minus adding my API key and URL etc:

`<?php //Version 4.0 $steamauth['apikey'] = "#######"; // Your Steam WebAPI-Key found at https://steamcommunity.com/dev/apikey $steamauth['domainname'] = "http://flintsdesigns.co.uk"; // The main URL of your website displayed in the login page $steamauth['logoutpage'] = "Index.php"; // Page to redirect to after a successfull logout (from the directory the SteamAuth-folder is located in) - NO slash at the beginning! $steamauth['loginpage'] = "Index.php"; // Page to redirect to after a successfull login (from the directory the SteamAuth-folder is located in) - NO slash at the beginning!

// System stuff if (empty($steamauth['apikey'])) {die("

SteamAuth:
Please supply an API-Key!
Find this in steamauth/SteamConfig.php, Find the '\$steamauth['apikey']' Array.
");} if (empty($steamauth['domainname'])) {$steamauth['domainname'] = $_SERVER['SERVER_NAME'];} if (empty($steamauth['logoutpage'])) {$steamauth['logoutpage'] = $_SERVER['PHP_SELF'];} if (empty($steamauth['loginpage'])) {$steamauth['loginpage'] = $_SERVER['PHP_SELF'];} ?> ` Any help appreciated

awoolstrum commented 5 years ago

Hi,

You have to register the resource user (your domain) inside of the the steam dev api. When you changed domain, you should change that registration with Steam. Did you do this?

BlackCetha commented 5 years ago

This sounds like you might be sending site content before including the library. Headers are required for the redirect, and once a single character of output is written, headers will be closed for the rest of the response. Make sure the include to the library is the first line of code in your file. PHP is very picky with this, even a single space before the opening code tag will throw it off.

@awoolstrum The domain you enter on the registration page is irrelevant.

Flinty916 commented 5 years ago

Hey so, I ended up being able to fix this. It was a complete idiot error. I had defined DOCTYPE html before my php on a few files. Was something silly that I shouldn't have missed. Nonetheless, it's fixed now. Thanks guys.