Running Hangout Apps

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.

Create a Google Developers Console project for your app

After you've published your Hangout gadget XML file, you must create a Google Developers Console project, an OAuth 2.0 client ID, and register your JavaScript origins, and enter the URL for your Hangout gadget XML file.

  1. Go to the Google Developers Console .
  2. Select a project, or create a new one by clicking Create Project:
    1. In the Project name field, type in a name for your project.
    2. In the Project ID field, optionally type in a project ID for your project or use the one that the console has created for you. This ID must be unique world-wide.
    3. Click the Create button and wait for the project to be created.
    4. Click on the new project name in the list to start editing the project.
  3. In the left sidebar, select the APIs item below "APIs & auth". A list of Google web services appears.
  4. Find the Google+ Hangouts API service and set its status to ON—notice that this action moves the service to the top of the list. You can turn off the Google Cloud services if you don't need them. Enable any other APIs that your app requires.
  5. In the sidebar under "APIs & auth", select Consent screen.
    1. Choose an Email Address and specify a Product Name.
  6. To the right of the Google+ Hangouts API service name, click on the gear icon . In the Application URL field, enter the URL where you publish your Hangout gadget XML file. Fill out other information requested on that page. Click Save.

You can then run your app privately, share your private apps with people outside your team, or publish your app for anyone to use.

Running your app privately

Before your app is marked as public in the Google Developers Console, any member of your project team may run it privately in any Hangout. Your team members are listed at Google Developers Console > choose your Hangout project > choose Permissions.

To run the app privately:

  1. Open a Hangout.
  2. Move the mouse pointer to the left edge of the Hangout to reveal the menu, choose the three dots (...), then Add apps. The app picker appears.
  3. Choose the Developer tab.
  4. Click the app that you want to run privately from the list of apps you have registered in the Google Developers Console.

The app loads and appears in the active apps list on the left with a special icon ( ) that indicates that it is running as a private app. Only project members of your Google Developers Console team will be able to see the app.

Private apps display a special toolbar at the top, which is labeled Manage Developed Apps. The toolbar contains four buttons, which are useful for debugging your app during development:

Share app
See sharing your private app.
Load app
Reopens the app picker, which allows you to open another public or private app.
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
Re-initializes the application state for the currently loaded Hangout app. This button clears the keys that are stored in the shared state. After resetting the app state, the app behaves as if you started it for the first time.

Sharing your private apps with people outside your team

You can allow the other participants in a Hangout to see and use your private apps for the duration of that Hangout. Use this option for previewing or beta testing your app with a limited audience. Participants who are not members of your project team will not be able to access the app in other Hangouts they join.

  1. You must create an OAuth 2.0 client ID before you can share an app.
  2. Click the Share app button on a private app to show the app in the active apps list of all other users. The app's entry will display a special icon ( ) that indicates that the app is a private app. If the user is not a member of your project team, they will need to accept a warning message, but otherwise the app will act as it would normally.

When you are ready to make this app fully 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:

  <Require feature="views"/>

Invia feedback per...

Google+ Hangouts API
Google+ Hangouts API