SmItH197 / SteamAuthentication

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

How to send a POST authorization request? #226

Closed Vlad-isLove closed 6 years ago

Vlad-isLove commented 6 years ago

I need to send a request for input by POST method, but not GET. To do this, I changed the loginbutton() function. In it was such the text: function loginbutton() { echo "<a href='?login'>Login</a>"; } I did it: function logoutbutton() { echo "<form action='' method='post'><button name='login' type='submit'>login</button></form>"; } I also changed the steamaut.php file. In it, I changed if (isset($_GET['login'])) to if (isset($_POST ['login'])) It didn't work. I click Login, I get on the Steam page, click Login, then I get on your site, but do not create SESSION. How to make POST authorization method work?

BlackCetha commented 6 years ago

You can read about how the information transfer works here: https://connect2id.com/learn/openid-connect

The redirect back to your page comes from steam's side and it will always be a GET request. Instead, you might want to redirect the user to a URL that only exists to set up your session with SteamAuth. Just make sure to handle what happens when the user calls the script and is already logged in and when they are not coming from steam (calling the script directly).

Edit: Reading through your post once more, it seems that you want to transfer data through the login process. That's not possible with either POST or GET. Steam will delete all unknown keys from the redirect address. You could start a session beforehand and save your data in the user's session, then update the data once they log in.