Skip to main content

OpenID 2.0 sign in for Steam

Project description

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 string

The string to pass is whatever page the user is going to be sent back to as a result of logging in with Steam.

from pysteamsignin.steamsignin import SteamSignIn

steamLogin = 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

#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

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

steamsignin-1.1.1.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

steamsignin-1.1.1-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file steamsignin-1.1.1.tar.gz.

File metadata

  • Download URL: steamsignin-1.1.1.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.2

File hashes

Hashes for steamsignin-1.1.1.tar.gz
Algorithm Hash digest
SHA256 f95cfcbf2c07e2b6fff8d129844981143592347532c931681a2cdd59c032e343
MD5 ec165562c53d1dea1e41d4245d08545b
BLAKE2b-256 e808ea7baec48ff4ca0bc86271665bd188658dec479288a72235e6a51dcebe14

See more details on using hashes here.

File details

Details for the file steamsignin-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: steamsignin-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.2

File hashes

Hashes for steamsignin-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c1b6253ff4e73dcad8c97ee0c5bb2cad0355c7ab1b0d77fa11ec88c6a420c01f
MD5 91ac34bba1c4256f4ec05fe4a05edc95
BLAKE2b-256 1ca730dd9a73702ecc365414198fdc8939983125cf7f41126edec9eac71929af

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page