Giter VIP home page Giter VIP logo

steam-openid-php's Introduction

PHPUnit PHPStan

Steam OpenID Authentication Library

A simple, modern and modular OpenID client library implementation for Steam.

Why this library?

This library aims to make the proccess of OpenID authentication with Steam as painless as possible.

As you may know, there are already a couple of libraries that do more or less the exact same thing as this library:

But as you may know or will see, those libraries are exactly what people hate about PHP. They do not use any real coding or php-fig (psr) standards, are not modular (they require cURL) and are generally a pain to work with because they do not throw exceptions.

How To Use

<?php declare(strict_types=1);

use danielburger1337\SteamOpenId\SteamOpenID;

// RECOMMENDATION: register this in your psr-11 container.
$openId = new SteamOpenID(
    // REQUIRED: your OpenID "realm" (your host)
    'http://localhost:5000',
    // REQUIRED: your OpenID "return_to" URI (your callback URI)
    'http://localhost:5000/Callback.php',
    // OPTIONAL: your psr-18 implementation (defaults to symfony/http-client)
    new GuzzleHttp\Client(),
    // OPTIONAL: your psr-17 implementation (default to nyholm/psr7)
    new Nyholm\Psr7\Factory\Psr17Factory()
);

// start the authentication flow by redirecting the user to Steam.
header('Location: ' . $openId->constructCheckIdSetupUri());

// ... in Callback.php (or your callback controller method)

use danielburger1337\SteamOpenId\Exception\ExceptionInterface;

// When steam redirects the user back to your "return_to" URI,
// verify the provided parameters in the query string.

try {
    // This method returns the users 64-bit SteamID.
    $steamId = $openId->verifyCallback($_GET);
} catch (ExceptionInterface $e) {
    exit(var_dump('Failed to verify steam authentication :('));
}

Terms & Conditions

Before using this library, please read and accept Valve's terms and conditions here.

steam-openid-php's People

Contributors

danielburger1337 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.