@acceleratxr/passport-steam
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

passport-steam

The Steam authentication strategy authenticates using OpenID Connect or Session Tokens as described in Steam documentation https://partner.steamgames.com/doc/features/auth.

This module lets you authenticate using Steam in your Node.js applications using the Passport framework.

Installation

npm install @acceleratxr/passport-steam

or

yarn add @acceleratxr/passport-steam

Usage

Configure Strategy

The Steam authentication strategy authenticates users using a Steam account and OAuth 2.0 tokens. The strategy requires a verify callback to perform a look up of the user account given a verified OAuth 2.0 token.

JavaScript

const SteamStrategy = require('@acceleratxr/passport-steam');

passport.use(new SteamStrategy({
    apiKey: STEAM_API_KEY,
    appID: STEAM_APP_ID,
    returnURL: "https://localhost:3000/callback",
    realm: "https://localhost:3000"
  }, function(steamID, _profile, done) {
    User.findOrCreate({steamId: steamID}, function (error, user) {
      return done(error, user);
    });
  }
));

TypeScript

import { SteamStrategy } from "@acceleratxr/passport-steam";

passport.use(new SteamStrategy({
    apiKey: STEAM_API_KEY,
    appID: STEAM_APP_ID,
    returnURL: "https://localhost:3000/callback",
    realm: "https://localhost:3000"
  }, function(steamID, _profile, done) {
    User.findOrCreate({steamId: steamID}, function (error, user) {
      return done(error, user);
    });
  }
));

Authenticate Requests

Use passport.authenticate(), specifying steam as the strategy to authenticate requests.

app.post('/auth/steam',
  passport.authenticate('steam'),
  function (req, res) {
    // do something with req.user
    res.send(req.user? 200 : 401);
  }
);

Client Requests (Session Tokens)

Clients can send requests to routes that use the passport-steam strategy using query params. Clients must transmit the session_token parameter that is received after Steam login.

GET /auth/steam?session_token=<TOKEN_HERE>

Client Requests (OpenID Connect)

Clients can send requests to routes that use the passport-steam strategy using query params. Clients must transmit the session_token parameter that is received after Steam login.

GET /auth/steam?mode=form_post&openid_identifier=<OPENID_IDENTIFIER>

Readme

Keywords

none

Package Sidebar

Install

npm i @acceleratxr/passport-steam

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

20.6 kB

Total Files

8

Last publish

Collaborators

  • acceleratxr