Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/teddio/pysteamsignin
A small Python 3 class designed to get Steam OpenID 2 sign-in up and running as quick as possible.
https://github.com/teddio/pysteamsignin
authentication bottlepy fastapi flask openid openid2 python steam steam-openid
Last synced: about 1 month ago
JSON representation
A small Python 3 class designed to get Steam OpenID 2 sign-in up and running as quick as possible.
- Host: GitHub
- URL: https://github.com/teddio/pysteamsignin
- Owner: TeddiO
- License: gpl-2.0
- Created: 2015-09-08T18:09:30.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2023-02-25T13:26:46.000Z (over 1 year ago)
- Last Synced: 2024-10-11T07:22:04.588Z (about 1 month ago)
- Topics: authentication, bottlepy, fastapi, flask, openid, openid2, python, steam, steam-openid
- Language: Python
- Homepage:
- Size: 35.2 KB
- Stars: 50
- Watchers: 4
- Forks: 10
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pySteamSignIn
A small Python 3 class designed to get Steam OpenID 2 sign-in up and running as quick as possible.As of this moment in time there's not really any 'decent' Steam Openid libraries that give any proper documentation or insight in terms of how to actually use them. Alongside this they're often fairly bloated and problematic. As a result of this pySteamSignIn is a lite class designed to let you plug in Steam Auth as quick as possible and let you start returning results immediately.
## Installation
pySteamSignIn is now available on pip!`pip install steamsignin`
## Lets quickly get authentication rolling
The power behind this is it provides the entire auth process over two (or three, if you're using bottlepy / Flask) functions.
The first function is ConstructURL, which takes a string and returns a stringThe string to pass is whatever page the user is going to be sent back to as a result of logging in with Steam.
```Python
from pysteamsignin.steamsignin import SteamSignInsteamLogin = SteamSignIn()
encodedData = steamLogin.ConstructURL('https://0.0.0.0:8080/processlogin'))
ForwardClientToSteamPage(encodedData) #Not a real function, but the next action you'd take
...
```At this point you forward the client on with a post request to https://steamcommunity.com/openid/login and you'll get thrown a bunch of stuff back.
The important thing here is that you get thet GET returned data put into a dictionary to then pass on to ValidateResults
```python
#Some function where the data has been passed in a dictionary no less
steamLogin = SteamSignIn()
returnedSteamID = steamLogin.ValidateResults(dictionaryGoesHere)
#Perform checks to see if you actually have something that isn't false
...
```
And that's the general gist of it! At this point the user has been validated by Steam's own servers so the Steam64ID returned is one that can be trusted and you can use it to store information, you can set cookies on the current client and so on.### If you use Bottlepy or Flask...
An additional helper function has been provided under the guise of RedirectUser.
This will just relay the user on your behalf to the Steam site, as such```Python
steamLogin = SteamSignIn()
steamLogin.RedirectUser(steamLogin.ConstructURL('https://0.0.0.0:8080/processlogin'))
# In the case of Flask, return the above RedirectUser call instead.
...
```## Finally
Hopefully this helps someone out in terms of getting Steam OpenID and Python working in harmony. There's a few solutions for Flask and Django (which are basically glorified wrappers for python-openid) but both of them can still result in a fair few steps.
This is based on OpenID 2.0 and **not** OpenID Connect 1.0.
If you require a Go version of this library, this is available [here](https://github.com/TeddiO/GoSteamAuth).