![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
express-battlenet-oauth
Advanced tools
OAuth Authentication for Battle.net (World of Warcraft, Starcraft 2 profiles) for ExpressJS
Handy sub-app for quickly adding Battle.net (https://dev.battle.net) OAuth to your express application.
####Installation
$ npm install express-battlenet-oauth
###Read Before Getting Started
See http://us.battle.net/en/forum/topic/13977887738#8 for more information.
###Easy to Implement
var express = require('express');
var app = express();
var bnet = require('express-battlenet-oauth');
var server = app.listen(8080, function() {
console.log('Listening on port %d', server.address().port);
});
app.set('BNET_ID', '[YOUR BATTLE.NET APPLICATION KEY/ID]');
app.set('BNET_SECRET', '[YOUR BATTLE.NET APPLICATION SECRET]');
app.set('BASE_URL', 'https://yoursecuredomain.com');
app.set('LOGIN_SUCCESS', function(req, res){
//battle.net oauth token is available in res.token_data for whatever your needs are
});
app.set('LOGIN_FAILURE', function(req, res){
//error is available in res.error for you to handle user permission denial or other errors
});
app.use('/', bnet);
//Setup your express app like normal
###Options All options for express-battlenet-oauth are set in your main express app via:
app.set('VARIABLE_NAME', value);
The only non-optional fields are BASE_URL, BNET_ID and BNET_SECRET, however, without setting a LOGIN_SUCCESS, LOGIN_FAILURE function you won't be able to do much useful with the authentication.
#####Options List
Name | Default | Description |
---|---|---|
BNET_REGION | 'us' | Changing the region you auth against. Valid values: us, eu, kr, tw, or cn |
BNET_SCOPE | 'wow.profile' | Changing the scope of your request. Valid values: wow.profile, sc2.profile |
BNET_AUTH_URL | '/auth/bnet' | This value is the route you want your Express app to use to begin BNET authentication. |
BNET_CALLBACK_URL | '/auth/bnet/callback' | This value is the route you want your Express app to use for the callback from the Blizzard OAuth API. This value has to match your applications "REGISTER CALLBACK URL" without your BASE_URL value. |
LOGIN_SUCCESS | function(req, res){ res.status(200).send('Use your own method to manipulate res.token_data, currently: ' + JSON.stringify(res.token_data))} | A function to handle a successful battle.net authentication, token data will be available at res.token_data |
LOGIN_FAILURE | function(req, res){ res.status(500).send(res.error) } | A function to handle a failed battle.net authentication (use declined access, bnet server errors, invalid grants, etc), error data will be available at res.error |
FAQs
OAuth Authentication for Battle.net (World of Warcraft, Starcraft 2 profiles) for ExpressJS
The npm package express-battlenet-oauth receives a total of 1 weekly downloads. As such, express-battlenet-oauth popularity was classified as not popular.
We found that express-battlenet-oauth demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.