Hi,
I am not a developer. I was using PassportJS to learn/play around with API authorisation, and using a boilerplate passport strategy (‘passport-twitch’) I could successfully get an access token, refresh token, and profile data. However I think it was using v5 (it said Kraken) auth endpoints so I switched to a generic passport OAuth2 strategy (‘passport-oauth2’) to use Helix. I successfully get an access token, refresh token, but the JSON returned is empty.
const express = require(“express”);
const passport = require(“passport”);
const OAuth2Strategy = require(“passport-oauth2”).Strategy;const keys = require(“./config/keys”);
const app = express();
const PORT = process.env.PORT || 5000;passport.use(new OAuth2Strategy({
authorizationURL: “https://id.twitch.tv/oauth2/authorize”,
tokenURL: “https://id.twitch.tv/oauth2/token”,
clientID: keys.twitchAuthID,
clientSecret: keys.twitchAuthSecret,
callbackURL: “/auth/twitch/callback”,
scope: “”
},
(accessToken, refreshToken, profile, cb) => {
console.log(“ACCESS TOKEN: \n”, accessToken);
console.log(“REFRESH TOKEN: \n”, refreshToken);
console.log(“PROFILE: \n”, profile.data);
//profile returns no data
}
));app.get(“/auth/twitch”, passport.authenticate(“oauth2”));
app.get(“/auth/twitch/callback”, passport.authenticate(“oauth2”, {failureRedirect: “/failed”}), (req, res) => {
// Successful authentication
res.redirect(“/”);
//console.log(res.status(OK, 200));
//console.log(“successful auth”)
})app.listen(PORT, () => {
console.log(“Server ready on http://www.localhost:”+PORT+“/”);
});
Response in console:
ACCESS TOKEN:
REMOVED
REFRESH TOKEN:
REMOVED
PROFILE:
{}
Again, I am not a developer so is this intended, what should I do next to retrieve data, how should I learn (the API documentation doesn’t really help me as I probably don’t have the knowledge to use the info there) ? Thank you