Estoy intentando autenticar al usuario y luego recuperar la lista de canales de YouTube.
A continuación se muestra la función para autenticar:
function authenticate() { showNewLoader('show'); return gapi.auth2.getAuthInstance() .signIn({scope: "https://www.googleapis.com/auth/youtube.readonly"}) .then(function(response) { console.log( response); youtubeAuthResponse['token_details'] = response.tc; youtubeAuthResponse['google_email'] = ''; youtubeAuthResponse['google_id'] = ''; showNewLoader('hide'); }, function(err) { console.error("Error signing in", err); showNewLoader('hide');}); }Cargando cliente:
function loadClient() { showNewLoader('show'); gapi.client.setApiKey("XXXXXX"); return gapi.client.load("https://www.googleapis.com/discovery/v1/apis/youtube/v3/rest") .then(function() { execute();}, function(err) { console.error("Error loading GAPI client for API", err);showNewLoader('hide');}); } /*Make sure the client is loaded and sign-in is complete before calling this method.*/ function execute() { return gapi.client.youtube.channels.list({ "part": [ "snippet", "statistics" ], "mine": true }) .then(function(response) { /*Handle the results here (response.result has the parsed body).*/ youtubeChannelResponse = response.result; storeYoutubeData(); }, function(err) { console.error("Execute error", err); showNewLoader('hide') }).then(function(){ }); }El usuario inicia sesión correctamente pero no puedo obtener la información del canal:
Cualquier ayuda sobre este tema es muy apreciada. @DalmTo