Skip to content
Meteor authentication for battlenet
JavaScript HTML CSS
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Battlenet for Meteor

Authenticate users on your site.



On the first use, you can use Configure Battlenet and follow the instructions to get set up.

Alternatively, You can manually set it up with service-configuration

$ meteor add service-configuration

then add something like this to your server-side code.

  service: "battlenet"

  service: "battlenet",
  clientId: "{ your client id }",
  secret: "{ your app's secret }"

Using authentication

When a user is authenticated, their profile will be populated with their World of Warcraft character list.

  _id: "akjdjsnaksdna",
  profile: {
    characters: [{
      achievementPoints: 7000,
      battlegroup: "Cyclone",
      class: 7,
      gender: 1,
      guild: "Ascension",
      guildRealm: "Draenor",
      level: 100,
      name: "Crowmo",
      race: 11,
      realm: "Draenor",
      spec: {
        backgroundImage: "bg-shaman-enhancement",
        description: "A totemic warrior who strikes foes with weapons imbued with elemental power.",
        icon: "spell_shaman_improvedstormstrike",
        name: "Enhancement",
        order: 1,
        role: "DPS"
      thumbnail: "draenor/someurl.jpg"

Making requests to

It's pretty easy to make requests to blizzard using Meteor.methods

  * Returns the profile of all guild members in a given guild
  * @param {String} realm the realm of the guild
  * @param {String} guildName the name of the guild
  * @returns {Object} an array of the members in the guild.
  getGuildMemberProfiles: function(realm, guildName) {
    // get the client ID
    var clientId = ServiceConfigurations.configurations.findOne({
service: "battlenet"});
    var baseUrl = "";
    var requestUrl = baseUrl + "/" + realm + "/" + guildName +"?fields=members&locale=en_US&apikey=" + apikey;

    var data = Meteor.http.get(requestUrl);
    return data.members;

You can then use to run this method, which passes the return values to the callback'getGuildMembers', 'Draenor', 'Ascension', function(error, members) {
  _.each(members, function(member)) {

View an example application

The directory example/ on github features a sample application. Try running it!

A warning: you will need to set up SSL and HTTPS:// first (see below).

$ cd example/
$ meteor

Known issues


In order to use this package with useraccounts, you must add accounts-ui to your project

$ meteor add accounts-ui


In order for this package to work, you must use https:// and SSL. You might see the following error message in your server console if it fails.

W20150318-16:05:20.101(-4) (oauth_server.js:78) Unable to parse state from OAuth query:
W20150318-16:05:20.102(-4) (oauth_server.js:78) Unable to parse state from OAuth query:
W20150318-16:05:20.103(-4) (oauth_server.js:398) Error in OAuth Server: invalid_request

Possible Solution on Mac OS X

Add a line to /etc/hosts to alias an https:// site.

Set up and install nginx

$ brew install nginx
$ mkdir -p /usr/local/etc/nginx/sites-enabled
$ vim /usr/local/etc/nginx/sites-enabled/

Here is a sample configuration

# Upstreams
upstream subdomain {

# HTTP Server
server {
  listen 80;
  rewrite ^ https://$server_name$request_uri permanent;
  try_files $uri/index.html $uri.html $uri @yoursite;

# HTTPS Server
server {
  listen 443 ssl;

  root /usr/share/nginx/html;
  error_log /usr/local/etc/nginx/sites-available/error.log crit;

  ssl_session_timeout 5m;
  ssl_certificate /usr/local/etc/nginx/ssl/;
  ssl_certificate_key /usr/local/etc/nginx/ssl/;
  ssl_prefer_server_ciphers on;
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

  location / {
    proxy_pass http://subdomain/;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forward-Proto http;
    proxy_set_header X-Nginx-Proxy true;
    proxy_redirect off;

Then, you must set the ROOT_URL of your application to be the https:// site and restart nginx

$ sudo nginx -s stop && sudo nginx
$ export ROOT_URL=""

Future feature plans

Please feel free to leave a request in the issues tab on this github page, or to submit a pull request. I am planning to implement the following in the Battlenet export for easier use:

  • Search through characters
  • Add extra scope, allowing fetching of more player details
  • Add features for guild support

Credit where credit is due.

Based on a number of other OAuth libraries. Credit to these guys for the guidance:

Also, big thanks to Stack overflow python for help with oauth as well.

You can’t perform that action at this time.