I am working on a project that helps YouTubers to access their youtube channels and update details video details. So far, I have created a youtube developer account, setup credentials and OAuth consent screen with youtube v3 API in scope.
I can successfully sign-in any user using the google sign-in button at the frontend (NextJS) and send the client id and credentials to the backend (NodeJS).
router.post("/google", function (req, res) { try { const { clientId, credential } = req.body; const user = jwt.decode(credential); console.log("clientId", clientId); console.log("user", user); return res.status(200).json({ message: "google", }); } catch (error) { console.log(error); return res.status(500).json({ message: error.message, data: error.data, errCode: 500, }); }})Now, I want to get youtube channel details and a list of videos of the signed user so I tried this,
const oauth2Client = new OAuth2( process.env.CLIENT_ID, process.env.CLIENT_SECRET, process.env.REDIRECT_URL);// get youtube channel detailsconst youtube = google.youtube({ version: "v3", auth: oauth2Client,});youtube.channels.list({ part: "snippet", id: user.googleId,},(err, data) => { if (err) { console.log("err", err); res.status(500).send(err); } else { console.log("data", data); res.status(200).send(data); }});But this code gives the error,
No access, refresh token, API key or refresh handler callback is set
Still, I don't under how this function will give signed youtube channels details when I am not providing any parameters to youtube API. Now, I am confused more than ever.
Can you help me figure out, how I can my app access others youtube channels? What am I missing here? 😫