Skip to content

APAC Region Doesn't Appear to Work #19

Open
@ryant26

Description

I'll include some code although, it's much more complex than what is necessary to reproduce this issue. (The code is from my application)

Essentially I set up a strategy to handle each of the login regions. us and eu work fine, apac doesn't appear to work. Not sure if this is an issue with this library since the getHost() method that resolves the regional OAuth endpoint is quite simple...

If this is the wrong place to open this issue, please let me know.

const bnetRegions = ['us', 'eu', 'apac'];
const port = 3003;
const domainName = `localhost:${port}`;

let generateAuthHandler = function(region) {
    return function (accessToken, refreshToken, profile, done) {
        done(null, {platformDisplayName: profile.battletag, region, platform: 'pc'});
    };
};

// Initialize bnet regional OAuth server strategies
bnetRegions.forEach((region) => {
    passport.use(`bnet-${region}`, new BnetStrategy({
        clientID: config.get('bnet.id'),
        clientSecret: config.get('bnet.secret'),
        callbackURL: `https://${domainName}/auth/bnet/callback?region=${region}`,
        region: `${region}`
    }, generateAuthHandler(region)));
});

router.get('/bnet', function (req, res, next) {
    passport.authenticate(`bnet-${req.query.region}`)(req, res, next);
});

router.get('/bnet/callback', function (req, res, next) {
    passport.authenticate(`bnet-${req.query.region}`, {
        failureRedirect: localAuthenticator.failureRedirect,
        session: false
    })(req, res, next);
}, authenticationService.serializeUser, authenticationService.generateToken, authenticationService.respond);

and the error:

{
    "message": "Failed to fetch the user id",
    "error": {
        "name": "InternalOAuthError",
        "message": "Failed to fetch the user id",
        "oauthError": {
            "code": "ENOTFOUND",
            "errno": "ENOTFOUND",
            "syscall": "getaddrinfo",
            "hostname": "apac.api.battle.net",
            "host": "apac.api.battle.net",
            "port": 443
        }
    },
    "title": "error"
}

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions