Hello guys
I’m trying to retrieve an Access Token and use it to make requests to the WoW GameDataAPI
In order to do that I had installed the passport-bnet npm package mentioned on the battle.net documentation
So I managed to use that with Express.js on local.
When I hit the route /auth/bnet it redirects me to
/auth/bnet/callback?code=“An access token in uppercase”
And after that I can’t access to my local host, my web browser says “ERR_CONNECTION_CLOSED”
The thing is that this token cannot be used, if I use it on http address like
eu .api.blizzard.com/data/wow/connected-realm/index?namespace=dynamic-eu&locale=fr_FR&access_token=The code given just before
I get an 401 error, so bad token I guess.
There is something that I don’t understand, I am a beginner and the documentation with the use of passportjs for the blizzardAPI is really thin.
Why does my Access Token doesn’t work ? And why does it doesn’t redirect me but instead my web browser shows an error ?
I would really appreciate some help, thanks.
Here are the snippet that I use
passport.use(
new BnetStrategy(
{ clientID: BNET_ID,
clientSecret: BNET_SECRET,
scope: 'wow.profile sc2.profile',
callbackURL: "https://localhost:3000/auth/bnet/callback",
region: "eu" },
function(accessToken, refreshToken, profile, done) {
process.nextTick(function () {
return done(null, profile);
});
})
);
// configure Express
app.get('/auth/bnet',
passport.authenticate('bnet'));
app.get('/auth/bnet/callback',
passport.authenticate('bnet', { failureRedirect: '/' }),
function(req, res){
res.redirect('/');
});
app.get("/", (req, res) => {
res.send('hello')
});