Search code examples
pythondjangosteamsteam-web-api

How can i use SteamAPI with Django?


How can this be possible? I am trying to add steam authentication button in my website and get general information: username, steam id.

something like this as example:

views.py:

# Example
from django.shortcuts import render
from django.http return HttpResponse

def index(response):
    ...
    return render('link.html', response) # link html contains <a> tag which should lead to steam authentication.
    ...

def afterauth(request):
    if auth = SteamAuth.wasSucessful:
        return HttpResponse("Username: " + SteamAuth.Username() + "SteamID: " + SteamAuth.ID())

I have gotten the API key, but i couldn't find any documentation regarding how to use it with Django.

Is there any way i can achieve this? Are there any tutorial's or documentation where i can use Steam API with Django?


Solution

  • You can use the python-social-auth package that has native support for both django and the steam API:

    Multiple frameworks are supported:

    • Django
    • Flask
    • Pyramid
    • Webpy
    • Tornado

    Auth providers

    • ...
    • Soundcloud OAuth2
    • Stackoverflow OAuth2
    • Steam OpenId
    • Stocktwits OAuth2
    • Strava OAuth2
    • Stripe OAuth2
    • ...