After you've written your Hangout app, it's time to actually run it inside of a hangout. This document walks you through that process.
Publish the app XML
If you haven't done so already, you must publish your Gadget XML file to a publicly accessible URL. Any stable URL will do, such as a repository on Google Project Hosting or an application on Google App Engine.
Note that any external JavaScript or CSS files your Hangout app uses do not necessarily need to be hosted at public URLs. They can be hosted on a private intranet site, for example, as long as the hangout participants are able to access them from their browser.
Register your app
After you've published your Gadget XML file, you must register your app in the Google APIs Console. Full documentation for using the APIs Console is available at Google APIs Console Help.
Once you have created a project in the APIs Console, activate the "Google+ Hangouts API" from the All Services pane. Once activated, a new Hangouts pane will be available from the sidebar. This page will allow you to enter the URL for your Gadget XML file, as well as to start a new hangout in the developer sandbox with your app running inside it. Be sure to save our changes.
Running your app in developer sandbox
Start a hangout in the developer sandbox with your app running in it as follows:
- Click the Enter a hangout! link at the bottom of the APIs Console.
The developer sandbox is distinguished by the presence of a red "Developer Preview" banner along the top.
You can invite people on your project team to view your app in the hangout. People outside your team will not able able to see your app in the developer sandbox
In the Hangout, you can load another app by either clicking the "Add app" button in the navigation bar, or click on the "Apps" tab in the App Switcher and click "Add app".
These buttons appear on the Manage Developer Apps navigation bar:
- Load app
- Opens a dialog box listing all your Hangout applications and extensions you have under development in the APIs Console. Click on an app to unload the currently running app and load a new instance of the selected app without starting a new hangout. Switching to a different app does not switch it for other participants in the hangout.
- Reload app
- Loads and parses the latest version of the Hangout XML file, while preserving the application state. Use this button to pick up new code changes.
- Reset app state
- Initialized the application state for the currently loaded Hangout app.
When you're ready to make this app public, follow the procedure at Publishing Apps.
Permissions and Authorization
An app with an OAuth 2.0 client ID will ask participants for permission to run the first time they try to use the app. Once a participant has agreed to these permissions, they won't be asked to agree to it again. A participant can revoke permission to the app by going to the Google Dashboard, clicking "Websites authorized to access the account", searching for the name of the app, and clicking "Revoke Access".
To enable the authorization dialog box in development mode, you must create an OAuth 2.0 client ID. All apps available to the public must have an OAuth2 client ID.
Also see I need an OAuth 2.0 access token. How do I get one?
Passing Data to the App
You can pass your app an initial set of data by adding the query
parameter gd=somevalue
. Your app can read this
query parameter's value using the following code:
var appData = gadgets.views.getParams()['appData'];
In order to read data passed to your app, make sure you have specifed the
"views" feature in the ModulePrefs
section of your
Gadget XML:
<ModulePrefs> <Require feature="views"/> </ModulePrefs>