Google AppEngineで作るGoogle Apps Marketplace
対応サービス
appengine ja night #102010年8月30日
なかじまんソフトウェア株式会社中嶋信博@nakajiman
Google API Expert (OpenSocial)
OpenSocial Pages for Google Appshttp://opensocial-pages.appspot.com/
• Google Apps のユーザとグ
ループをソーシャルグラフとして、ドメイン専用 OpenSocialコンテナが持てる
• PC に加えて Smart Phone でも OpenSocialガジェットが快適に動作するアーキテクチャ
• Google AppEngineでホストして Google Apps Marketplace に対応
• ソースコードも入手可
本日のゴール
• Google Apps Marketplace とは何か
Google Apps に Product をインストールするとはどういうことか
• Application Manifestとは何か
Google Apps Marketplaceに Product を掲載する手順
• AppEngineから OpenID Single-Sign On と 2-legged OAuth for Data を使って Google Apps と連携する方法
• 情報源
Google Apps Marketplace とは何か
Google Apps Marketplacehttp://www.google.com/enterprise/marketplace/
GoogleApps
Vendor
利用
利用
提供
Google Apps Marketplace主な Vendor
6
Google Apps Marketplace に掲載できる内容と条件
• Vendor (会社情報)• Product (製品情報)
– Installable (直接インストール)• OpenID Single-Sign On
–Google AppEngine–その他
• Gmail Contextual Gadget
–Not Installable
• Service (サービス情報)
Vendor(会社情報)
Product(製品情報)
Customer Review(レビュー)
Add it now(インストールボタン)
Installable な Productを利用できるGoogle Apps Edition とユーザ
• Google Apps Edition–Premier
–Standard
–Education, Government, Non-profit ?• User Privileges (権限)
– Administrator (管理者) --インストールと設定
– User (一般) --利用
未確認教えてください
Product をインストールするとGoogle Apps のサービスの1つになる
Administrator(管理者)
User(一般)
Google Apps Developer Program SiteSell Marketplace Apps
Payment Policyhttp://developer.googleapps.com/marketplace/fees
Revenue shareVender : Google = 80 : 20
Google Checkout APIAutomatic Billing or Self Reported Billing
Google Apps MarketplaceからGoogle Apps に Product をインストールするとはどういうことか
Google Apps MarketplaceからGoogle Apps に Product をインストール
Add it now ボタン
をクリックして …
Google Apps ドメイン名
を入力して GO
すると … Google Apps に遷移する
Google Apps Marketplace 及びProduct の利用規約への同意
利用規約はProduct (製品情報)で設定する
Product から Google Apps へのデータアクセスの許可
データアクセスの範囲と理由はApplication Manifestで定義する
Product は Google AppEngineでホストし、マルチテナントな構成
GoogleApps
GoogleApps Marketplace
Google AppEngine
Add it now ボタン利用規約の同意データアクセスの認可
ログイン OpenID Single Sign-Onデータアクセス 2-legged OAuth for Data
Product の利用
http://opensocial-pages.appspot.com/a/${DOMAIN_NAME}/
ApplicationManifest
<?xml version<ApplicationManifestxmlns= …
Application Manifest とは何か
Application Manifest 1/4製品のサポート情報
<?xml version="1.0" encoding="UTF-8" ?>
<ApplicationManifestxmlns="http://schemas.google.com/ApplicationManifest/2009">
<Support>
<Link rel="manage" href="http://opensocial-pages.appspot.com
/a/${DOMAIN_NAME}/controlpanel“ /> <!–製品の管理ページ -->
<Link rel="support" href="http://sites.google.com/a/lrlab.to/opensocial-pages/" />
</Support> <!–製品のサポートページ -->
<Name>OpenSocial Pages</Name> <!–製品名 -->
Application Manifest 2/4Google's Universal Navigation
<Extension id="navLink" type="link">
<Name>OpenSocial Pages</Name> <!– リンク名 -->
<Url>http://opensocial-pages.appspot.com/a/${DOMAIN_NAME}/</Url> <!– リンク先 -->
<Scope ref="UserFeed" />
<Scope ref="GroupFeed" />
</Extension>
Google‘sUniversal Navigation
Application Manifest 3/4OpenID承認ステップのスキップ
<Extension id="realm" type="openIdRealm">
<Url>http://opensocial-pages.appspot.com</Url>
</Extension>インストールした時点で許可したとみなして
スキップして表示しない
Application Manifest 4/4データアクセスの範囲と理由
<Scope id="UserFeed"> <!– Provisioning API (read only) -->
<Url>https://apps-apis.google.com/a/feeds/user/#readonly</Url>
<Reason>For the admin interface: This allows you …</Reason>
</Scope>
<Scope id="GroupFeed"> <!– Provisioning API (read only) -->
<Url>https://apps-apis.google.com/a/feeds/group/#readonly</Url>
<Reason>For the admin interface: This allows you …</Reason>
</Scope>
</ApplicationManifest>
Google Apps MarketplaceにProduct を掲載する手順
Google Apps MarketplaceProduct の開発から公開までの流れ
Vendor (会社情報) とProduct (製品情報)の登録
Product の開発とテストVendor は公開前でもインストールできる
Google Marketplace への公開申請Google Checkout で 100 ドル支払い
Google Marketplace による審査結果は48時間以内にメールで通知
Google Marketplace の掲載開始誰でもインストールできる
Vendor (会社情報)
• Company logo
• Vendor name
• Phone number
• Email address
• Home page URL
• Address line
• Town
• Zip/post code
• Country
• Vendor overview
Product (製品情報)
• My product may be directly installed into Google Apps domains• Category• Name• Summary Overview• Full Overview• Application Manifest• Pricing Summary• Terms of Service• Benefit points / External links• Screenshot / Logo• Screencast / Video or success story collateral• Version information• Google Analytics• Google APIs
On
OpenID Single-Sign On:Google OpenID Federated Login
Authentication Options:(Experimental) Federated Login
Google AppEngineApplication Settings
ログイン画面への誘導
UserService userService =UserServiceFactory.getUserService();
String loginUri = userService.createLoginURL("/", // ログイン後のリダイレクト先
"","n35.com", // Google Apps ドメイン名
new HashSet<String>() // 無効っぽい?
);response.sendRedirect(loginUri);
ログアウト画面への誘導
UserService userService =
UserServiceFactory.getUserService();
String logoutUrl =
userService.createLogoutURL("/");
request.setAttribute("logoutUrl", logoutUrl);
UserServiceで取得できる情報 1/2
UserService userService = UserServiceFactory.getUserService();
User user = userService.getCurrentUser();
user.getAuthDomain(); // ドメイン名じゃないので注意!
https://www.google.com/a/n35.com/o8/ud?be
user.getUserId();
102200252690973622441
user.getFederatedIdentity(); http://n35.com/openid?id=114998333651267920533
user.getEmail();
user.getNickname(); // 名前は AX で取得できない?
UserServiceで取得できる情報 2/2
UserService userService = UserServiceFactory.getUserService();
userService.isUserAdmin();
true // Google Apps の Administrator ではないです!
userService.isUserLoggedIn();
true
2-legged OAuth for Data:Google Apps Provisioning API
Google Data Java Client Library
Google Apps Provisioning API で必要なファイル
• gdata-core-1.0.jar
• gdata-client-1.0.jar
• gdata-appsforyourdomain-1.0.jar
View OAuth Consumer KeyConsumer Key / Key Secret
GoogleOAuthParameters params = new GoogleOAuthParameters();
params.setOAuthConsumerKey("Consumer Key");
params.setOAuthConsumerSecret("Consumer Secret");
params.setOAuthType(OAuthType.TWO_LEGGED_OAUTH);
Google Apps MarketplaceVender (会社情報)
Google Apps Provisioning APIUser 情報の取得
UserService service = new UserService("User");
service.setOAuthCredentials(params, new OAuthHmacSha1Signer());
service.useSsl();
URL url = new URL("https://apps-apis.google.com/a/feeds" +
"/n35.com/user/2.0/nakajiman");
UserEntry user = service.getEntry(url, UserEntry.class);
String givenName = user.getName().getGivenName();
String familyName = user.getName().getFamilyName();
boolean admin = user.getLogin().getAdmin();
Google Apps Provisioning APIGroup 情報の取得
AppsPropertyService service =
new AppsPropertyService("AppsProperty");
service.setOAuthCredentials(params, new OAuthHmacSha1Signer());
service.useSsl();
URL url = new URL("https://apps-apis.google.com/a/feeds" +
"/group/2.0/n35.com/[email protected]");
GenericEntry group = service.getEntry(url, GenericEntry.class);
String title = group.getProperty("groupName");
String description = group.getProperty("description");
Google Apps Provisioning API Group メンバー情報の取得
AppsPropertyService service =
new AppsPropertyService("AppsProperty");
service.setOAuthCredentials(params, new OAuthHmacSha1Signer());
service.useSsl();
URL url = new URL("https://apps-apis.google.com/a/feeds" +
"/group/2.0/n35.com/[email protected]/member");
GenericFeed members = service.getFeed(url, GenericFeed.class);
for (GenericEntry member : members.getEntries()) {
String memberId = member.getProperty("memberId");
情報源
Google Apps Marketplacehttp://www.google.com/enterprise/marketplace/
Google Apps Developer Program Sitehttp://developer.googleapps.com/
Google Apps APIs (en)http://code.google.com/intl/en/googleapps/
Google Data Java Client Libraryhttp://code.google.com/p/gdata-java-client/
OpenSocial Pages for Google Appshttp://opensocial-pages.appspot.com/
Top Related