Reputation: 17616
Using Google's developper console:
Node server initial steps:
var url = oauth2Client.generateAuthUrl({
access_type: 'offline', //returns fresh token,
scope: 'https://www.googleapis.com/auth/youtube https://www.googleapis.com/auth/youtube.upload https://www.googleapis.com/auth/youtube.force-ssl https://www.googleapis.com/auth/youtubepartner'
});
Google Authorization page:
Node Server final steps:
oauth2Client.getToken(code, function (err, tokens) {
// set tokens to the client
console.log('errors ' + err);
console.log('tokens ' + tokens);
oauth2Client.setCredentials(tokens);
})
The result from the console.log's are:
errors Error: invalid_request
tokens null
What is causing the invalid_request
? What part did I miss?
Some other similar questions propose different solutions
There seem to be quite a few questions on this subject, but most are specific questions with too often very vague answers. I'm asking a generic question and looking for a specific answer.
Upvotes: 2
Views: 2033
Reputation: 2767
You didn't mention constructing of oauth2Client instance, so it can be a problem from lib issue on GutHub google-api-nodejs-client/issues/231
Namely, the third argument in constructor OAuth2 is going be a string
client_secrets.web.redirect_uris[0]
var oauth2Client = new OAuth2Client(
client_secrets.web.client_id,
client_secrets.web.client_secret,
client_secrets.web.redirect_uris[0] //<-- take first uri
);
Upvotes: 5