Google Apps Marketplace manifestファイルの書き方

Google Apps Marketplace manifestファイルの書き方についてまとめて置きます。
日本ではまだ2011年1月11日現在では、Billing APIは使えないのフリーで公開するために必要となると思われる箇所のみメモしました。
Google Apps Marketplaceにアプリを登録する方法については以下の記事が参考にしてください。

そして、manifestファイルの書き方は、本家サイトでは以下のページに記載されています。
Application Manifest - Google Apps Marketplace - Google Code(本家サイト)

チュートリアルのサンプルファイルはこんな感じです。

<?xml version="1.0" encoding="UTF-8" ?>
<ApplicationManifest xmlns="http://schemas.google.com/ApplicationManifest/2009">

  <!-- Support info to show in the marketplace & control panel -->
  <Support>
    <!-- URL for application setup as an optional redirect during the install -->
    <Link rel="setup" href="http://www.example.com/google/setup.php?domain=${DOMAIN_NAME}" />

    <!-- URL for application configuration, accessed from the app settings page in the control panel -->
    <Link rel="manage" href="http://www.example.com/google/admin.php?domain=${DOMAIN_NAME}" />

    <!-- URL explaining how customers get support. -->
    <Link rel="support" href="http://www.example.com/google/support.php" />

    <!-- URL that is displayed to admins during the deletion process, to specify policies such as data retention, how to claim accounts, etc. -->
    <Link rel="deletion-policy" href="http://www.example.com/google/deletion-policy.php" />
  </Support>

  <!-- Name and description pulled from message bundles -->
  <Name>AppTest</Name>
  <Description>A simple application for testing the marketplace</Description>

  <!-- Show this link in Google's universal navigation for all users -->
  <Extension id="navLink" type="link">
    <Name>AppTest</Name>
    <Url>http://www.example.com/home.php?from=google&amp;domain=${DOMAIN_NAME}</Url>
    <!-- This app also uses the Calendar API -->
    <Scope ref="calendarFeed"/>
  </Extension>

  <!-- Declare our OpenID realm so our app is white listed -->
  <Extension id="realm" type="openIdRealm">
    <Url>http://www.example.com</Url>
  </Extension>

  <!-- Need access to the Calendar feed -->
  <Scope id="calendarFeed">
    <Url>http://www.google.com/calendar/feeds/</Url>
    <Reason>This application shows the next Calendar event.</Reason>
  </Scope>

</ApplicationManifest>

Support要素

Support要素には、アプリケーション独自の管理ページを指定するLink要素を子要素として指定します。
管理ページの種類はrel属性で指定します。

@rel="support"

アプリケーションのサポートサイトのページのURLを指定します。

@rel="setup"

アプリケーションインストール時に独自のセットアップが必要な場合は、セットアップページのURLを指定します。
href属性に指定したURL内の「${DOMAIN_NAME}」はドメイン名に置換されます。
このLink要素が指定してあった場合、以下の用にSTEP2で指定したURLのリンクが表示されます。

アプリケーション側はセットアップ終了後、callbackパラメータで送られてくるURLにリダイレクトすると、STEP3のアプリケーション有効化のページが表示されるようになります。

@rel="manage"

インストール後の管理ページがある場合は、そのURLを指定します。
href属性に指定したURL内の「${DOMAIN_NAME}」はドメイン名に置換されます。
ドメイン管理のアプリケーションの管理ページを開くと以下の箇所にリンクが表示されます。
setupもmanageもラベルが「追加の設定」なのは翻訳ミスでしょうか。両方指定してある場合は2番目の「追加の設定」がmanageに指定したhrefになります。

setupのページが終了しなくても、アプリケーションのインストールステップは先に進むことはできてしまいます。
setupのみ指定して、初期設定かどうかはアプリケーション側でハンドリングしたほうが良さそうです。

@rel="deletion-policy"

アプリケーション削除時に呼び出されるページのURLを指定します。
アプリケーションを削除する際に以下のリンクが表示されます。

ドメイン情報の掃除処理などを実行するページを指定したいところですが、リンクをクリックしなくてもアプリケーションは削除されてしまうので、ドメインのデータが残ったままになってしまう可能性があります。

Extension要素

Extension要素は、Google Appsのナビゲーションリンクに指定するOpenIDログインのリンクや、課金の際のエディションを指定します。

@type="link"

アプリケーションのナビゲーションリンクに追加される、アプリケーションにログインするリンクを指定します。

 <Extension id="navLink" type="link">
    <Name>CakeForm</Name>
    <Url>http://www.cakeform.net/forms/login?hd=${DOMAIN_NAME}</Url>
    <Scope ref="documentListAPI"/>
    <Scope ref="spreadsheetsDataAPI"/>
 </Extension>

子要素として以下の要素を指定します。

  • Name:メニューのタイトル
  • Url:メニューに張るリンクのURL、通常「${DOMAIN_NAME}」に置換されるドメインOpenIDログインするアクションを指定します。
  • Scope:2 Legged OAuthでアクセスするAPIのスコープを指定します。上記の例ではDocumentList APIとSpreadsheet APIにアクセス許可を求めています。また、このScope要素はref属性で参照されるidを持つScope要素を参照しています(後述参照)。
@type="openIdRealm"

OpenIDホワイトリストとして登録されるUrlを指定します。

  <Extension id="realm" type="openIdRealm">
    <Url>http://www.cakeform.net/</Url>
  </Extension>

Scope要素

Scope要素は、アプリケーションが2 Legged OAuthでアクセスする必要があるAPIを指定します。
id属性は、Extension要素のScope要素のref属性の値に対応させます。

  <Scope id="documentListAPI">
    <Url>https://docs.google.com/feeds/</Url>
    <Reason>This app add a new SpreadSheet to Google Documents with Google Document List API.</Reason>
  </Scope>
  <Scope id="spreadsheetsDataAPI">
    <Url>https://spreadsheets.google.com/feeds/</Url>
    <Reason>This app update a SpreadSheet on Google Documents with Google Spreadsheets Data API.</Reason>
  </Scope>

上記の例では、Document List APIとSpreadsheets Data APIへのアクセスの許可を求めます。
アクセスするAPIとUrlの対応表はSupported Scopesに記載されています。
Scopeで指定したAPIは、アプリケーションのインストール時にアクセス許可が必要なAPIとしてリストアップされます。