Closed Caio-P-B closed 4 years ago
Estou com esse erro ao tentar fazer o primeiro teste do penúltimo vídeo da série [YouTube API: tutorial para upload de vídeos (OAuth2)]
(node:13404) UnhandledPromiseRejectionWarning: TypeError: Cannot read property '0' of undefined at createOAuthClient (C:\Users\Desktop\Desktop\Testes-HTML\four-robots-project\the-four-robots\robots\youtube.js:44:46) at authenticateWithOAuth (C:\Users\Desktop\Desktop\Testes-HTML\four-robots-project\the-four-robots\robots\youtube.js:15:35) at processTicksAndRejections (internal/process/task_queues.js:93:5) at async Object.robot [as youtube] (C:\Users\Desktop\Desktop\Testes-HTML\four-robots-project\the-four-robots\robots\youtube.js:9:5 ) at async start (C:\Users\Desktop\Desktop\Testes-HTML\four-robots-project\the-four-robots\index.js:14:5) (Use
node --trace-warnings ...
to show where the warning was created) (node:13404) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an asyn c function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unha ndled promise rejection, use the CLI flag--unhandled-rejections=strict
(see https://nodejs.org/api/cli.html#cli_unhandled_rejection s_mode). (rejection id: 2) (node:13404) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Então estou com o mesmo problema, você conseguiu resolver?
Assim que conseguir volto com a solução.
Achei uma solução pra mim que funcionou e gostaria de compartilhar:
Em robots/youtube.js Na linha : 41
async function createOAuthClient() { const credentials = require('../credentials/google-youtube.json')
const OAuthClient = new OAuth2(
credentials.web.client_id,
credentials.web.client_secret,
//credentials.web.redirect_uris[0]
credentials.web.redirect_uris["http://localhost:5000/oauth2callback"]
)
return OAuthClient
}
function requestUserConsent(OAuthClient) {
const consentUrl = OAuthClient.generateAuthUrl({
access_type: 'offline',
scope: ['https://www.googleapis.com/auth/youtube']
})
//Alterei esse log no console para mostrar o link completo com o callback
console.log(`> [youtube-robot] Por favor, de seu consentimento: ${consentUrl}`+`http://localhost:5000/oauth2callback`)
}
Pra mim funcionou. Diga aí se funcionou pra você.
Estou com esse erro ao tentar fazer o primeiro teste do penúltimo vídeo da série [YouTube API: tutorial para upload de vídeos (OAuth2)]
(node:13404) UnhandledPromiseRejectionWarning: TypeError: Cannot read property '0' of undefined at createOAuthClient (C:\Users\Desktop\Desktop\Testes-HTML\four-robots-project\the-four-robots\robots\youtube.js:44:46) at authenticateWithOAuth (C:\Users\Desktop\Desktop\Testes-HTML\four-robots-project\the-four-robots\robots\youtube.js:15:35) at processTicksAndRejections (internal/process/task_queues.js:93:5) at async Object.robot [as youtube] (C:\Users\Desktop\Desktop\Testes-HTML\four-robots-project\the-four-robots\robots\youtube.js:9:5 ) at async start (C:\Users\Desktop\Desktop\Testes-HTML\four-robots-project\the-four-robots\index.js:14:5) (Use
node --trace-warnings ...
to show where the warning was created) (node:13404) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an asyn c function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unha ndled promise rejection, use the CLI flag--unhandled-rejections=strict
(see https://nodejs.org/api/cli.html#cli_unhandled_rejection s_mode). (rejection id: 2) (node:13404) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.