Hi All, I have a use-case where I want to run the hangout app in a standalone container instead of the Google Hangout. For that, I'm trying to run my Gadget XML inside the Shindig container. The Gadget XML consist of authentication with Google+ which works fine. After that I'm trying to access the hangout APIs. But, the APIs are returning false and empty values. (Attaching the sample XML file here).
Code snippet for the first hangout api is, function startMyApp() { console.log("Hurray API Ready"); } function init() { try { gapi.hangout.onApiReady.add(function (eventObj) { if (eventObj.isApiReady) { startMyApp(); } }); } catch (e) { console.log(e.stack); } } Please let me know if there is anything additional handling required in the code? Thanks, Sagar. [http://www.agreeyamobility.net/logo.png] Unified Collaboration and Communication for Office 365, SharePoint, and Lync http://www.onvelop.com | Available on Android | iOS | Windows 8
<Module> <!-- Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License -->  <ModulePrefs title="Hangout Starter">   <Require feature="rpc" />   <Require feature="views" />   <Require feature="locked-domain" />  </ModulePrefs>  <Content type="html"><![CDATA[ <html> <head> <meta charset='utf-8' /> </head> <body> <!--Add a button for the user to click to initiate auth sequence --> <button id="authorize-button" style="visibility: hidden">Authorize</button> <button id="hangout-button" style="visibility: hidden">Start Hangout</button> <script type="text/javascript"> // Enter a client ID for a web application from the Google Developer Console. // The provided clientId will only work if the sample is run directly from // https://google-api-javascript-client.googlecode.com/hg/samples/authSample.html // In your Developer Console project, add a JavaScript origin that corresponds to the domain // where you will be running the script. var clientId = '710312979794-154s6s6pj6dlscdvairlke4n7ja4i126.apps.googleusercontent.com'; // Enter the API key from the Google Develoepr Console - to handle any unauthenticated // requests in the code. // The provided key works for this sample only when run from // https://google-api-javascript-client.googlecode.com/hg/samples/authSample.html // To use in your own application, replace this API key with your own. var apiKey = 'AIzaSyBmmNVgH6eWER-dZySoX6gxuIDo2KAXTQY'; // To enter one or more authentication scopes, refer to the documentation for the API. var scopes = ['https://www.googleapis.com/auth/plus.me','https://www.googleapis.com/auth/hangout.av','https://www.googleapis.com/auth/hangout.participants']; // Use a button to handle authentication the first time. function handleClientLoad() { gapi.client.setApiKey(apiKey); //window.setTimeout(checkAuth,1); gapi.client.load('oauth2', 'v2', checkAuth); gapi.hangout.onApiReady.add(addCallback); } function addCallback(eventObj) { console.log("Inside onApiReady.add"); if (eventObj.isApiReady) { console.log("Hurray API Ready"); } } function checkAuth() { console.log("Inside checkAuth"); gapi.auth.authorize({client_id: clientId, scope: scopes, immediate: true}, handleAuthResult); } function startMyApp() { console.log("Hurray API Ready"); } function init() { console.log("Hurray Init Called"); try { gapi.hangout.onApiReady.add(function (eventObj) { if (eventObj.isApiReady) { startMyApp(); } }); } catch (e) { console.log(e.stack); } } function handleAuthResult(authResult) { if (authResult) { if (authResult['error'] == undefined) { gapi.auth.setToken(authResult); // Store the returned token. } } var authorizeButton = document.getElementById('authorize-button'); if (authResult && !authResult.error) { authorizeButton.style.visibility = 'hidden'; makeApiCall(); } else { authorizeButton.style.visibility = ''; authorizeButton.onclick = handleAuthClick; } } function handleAuthClick(event) { gapi.auth.authorize({client_id: clientId, scope: scopes, immediate: false}, handleAuthResult); return false; } // Load the API and make an API call. Display the results on the screen. function makeApiCall() { gapi.client.load('plus', 'v1', function() { var request = gapi.client.plus.people.get({ 'userId': 'me' }); request.execute(function(resp) { var heading = document.createElement('h4'); var image = document.createElement('img'); image.src = resp.image.url; heading.appendChild(image); heading.appendChild(document.createTextNode(resp.displayName)); document.getElementById('content').appendChild(heading); }); }); var hangoutButton = document.getElementById('hangout-button'); hangoutButton.style.visibility = ''; hangoutButton.onclick = handleHangoutClick; } function handleHangoutClick(event) { var hangoutButton = document.getElementById('hangout-button'); var authorizeButton = document.getElementById('authorize-button'); try { console.log("isApiReady : " + gapi.hangout.isApiReady()); console.log("isAppVisible : " + gapi.hangout.isAppVisible()); console.log("isPublic : " + gapi.hangout.isPublic()); console.log("getPreferredLocale : " + gapi.hangout.getPreferredLocale()); } catch(e) { console.log(e.stack); } if (gapi.hangout.isApiReady()) { showParticipants(); } return false; } function showParticipants() { console.log("Sagar Inside showParticipants"); console.log("getHangoutUrl : " + gapi.hangout.getHangoutUrl()); console.log("getHangoutId : " + gapi.hangout.getHangoutId()); var participants = gapi.hangout.getParticipants(); var retVal = '<p>Participants: </p><ul>'; for (var index in participants) { var participant = participants[index]; if (!participant.person) { retVal += '<li>A participant not running this app</li>'; } retVal += '<li>' + participant.person.displayName + '</li>'; } retVal += '</ul>'; var div = document.getElementById('participantsDiv'); div.innerHTML = retVal; } // Wait for gadget to load. gadgets.util.registerOnLoadHandler(init); </script> <script type="text/javascript" src="//www.google.com/jsapi"></script> <script type="text/javascript">google.load("jquery", "1.6.4");</script> <script src="https://apis.google.com/js/client.js?onload=handleClientLoad"></script> <script src="https://hangoutsapi.talkgadget.google.com/talkgadget/apps/gadgets/js/rpc.js"></script> <script src="https://hangoutsapi.talkgadget.google.com/hangouts/api/hangout.js?v=1.4"></script> <div id="participantsDiv"></div> <hr> <div id="content"></div> <p>Retrieves your profile name using the Google Plus API.</p> </body> </html> ]]> </Content> </Module>