Skip to main content

OpenID 2.0 sign in for Steam

Project description

pySteamSignIn

A lightweight Python 3 helper class for getting OpenID 2.0 Steam sign-in up and running quickly.

There aren’t really any Steam-specific OpenID 2.0 sign-in libraries that provide clear documentation or insight into how the flow actually works. Most guidance instead points people at generic OpenID libraries, which are often overkill for Steam and fairly bloated in practice.

As a result of this pySteamSignIn is 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 / FastAPI) 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.

If you use Bottlepy, Flask or FastAPI...

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 / FastAPI, return the above RedirectUser call instead.
...

Dependencies

The core of pySteamSignIn uses only the Python standard library and does not depend on external HTTP clients such as requests. Optional helper functions are provided for common web frameworks (Bottle, Flask, FastAPI) and are only enabled if those frameworks are already installed.

Finally

Hopefully this helps someone get OpenID 2.0 Steam sign-in and Python working together a bit more smoothly. 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 / OAuth 2.

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.2.tar.gz (11.6 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.2-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for steamsignin-1.1.2.tar.gz
Algorithm Hash digest
SHA256 2b77aaaf4239d345cb3c2369bad211eef231fd3ebebbb58f1123b5b6f2fb14e0
MD5 50658e39d9093b5f42ce16ce9713889e
BLAKE2b-256 2e55d5ed25fb1aa3b8b5dee6a77b26b89bbff836a0569818a29ff8eebb4cc2ab

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for steamsignin-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e82e455f442e5d1f15fa106fc1303c1f95700bfeb1e0d59437c7bda1ee468a15
MD5 cdba51b9bccf49d95399dc6b963f5228
BLAKE2b-256 0cda05032e570673f4013a4d42da6e7a27c3264fec10ae57ede5228c8141a9e1

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