appengine ja night #10 google appengine で作る google apps marketplace 対応サービス

38
Google AppEngine で作る Google Apps Marketplace 対応サービス appengine ja night #10 2010830なかじまんソフトウェア株式会社 中嶋 信博 @nakajiman Google API Expert (OpenSocial)

Upload: nakajiman-software-inc

Post on 07-Nov-2014

6.308 views

Category:

Technology


1 download

DESCRIPTION

• Google Apps Marketplace とは何か • Google Apps にProduct をインストールすると はどういうことか • Application Manifest とは何か Google Apps Marketplace にProduct を掲載す る手順 • AppEngine からOpenID Single-Sign On と2- legged OAuth for Data を使ってGoogle Apps と 連携する方法 • 情報源

TRANSCRIPT

Page 1: appengine ja night #10 Google AppEngine で作る Google Apps Marketplace 対応サービス

Google AppEngineで作るGoogle Apps Marketplace

対応サービス

appengine ja night #102010年8月30日

なかじまんソフトウェア株式会社中嶋信博@nakajiman

Google API Expert (OpenSocial)

Page 2: appengine ja night #10 Google AppEngine で作る Google Apps Marketplace 対応サービス

OpenSocial Pages for Google Appshttp://opensocial-pages.appspot.com/

• Google Apps のユーザとグ

ループをソーシャルグラフとして、ドメイン専用 OpenSocialコンテナが持てる

• PC に加えて Smart Phone でも OpenSocialガジェットが快適に動作するアーキテクチャ

• Google AppEngineでホストして Google Apps Marketplace に対応

• ソースコードも入手可

Page 3: appengine ja night #10 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 と連携する方法

• 情報源

Page 4: appengine ja night #10 Google AppEngine で作る Google Apps Marketplace 対応サービス

Google Apps Marketplace とは何か

Page 5: appengine ja night #10 Google AppEngine で作る Google Apps Marketplace 対応サービス

Google Apps Marketplacehttp://www.google.com/enterprise/marketplace/

GoogleApps

Vendor

利用

利用

提供

Page 6: appengine ja night #10 Google AppEngine で作る Google Apps Marketplace 対応サービス

Google Apps Marketplace主な Vendor

6

Page 7: appengine ja night #10 Google AppEngine で作る Google Apps Marketplace 対応サービス

Google Apps Marketplace に掲載できる内容と条件

• Vendor (会社情報)• Product (製品情報)

– Installable (直接インストール)• OpenID Single-Sign On

–Google AppEngine–その他

• Gmail Contextual Gadget

–Not Installable

• Service (サービス情報)

Page 8: appengine ja night #10 Google AppEngine で作る Google Apps Marketplace 対応サービス

Vendor(会社情報)

Product(製品情報)

Customer Review(レビュー)

Add it now(インストールボタン)

Page 9: appengine ja night #10 Google AppEngine で作る Google Apps Marketplace 対応サービス

Installable な Productを利用できるGoogle Apps Edition とユーザ

• Google Apps Edition–Premier

–Standard

–Education, Government, Non-profit ?• User Privileges (権限)

– Administrator (管理者) --インストールと設定

– User (一般) --利用

未確認教えてください

Page 10: appengine ja night #10 Google AppEngine で作る Google Apps Marketplace 対応サービス

Product をインストールするとGoogle Apps のサービスの1つになる

Administrator(管理者)

User(一般)

Page 11: appengine ja night #10 Google AppEngine で作る Google Apps Marketplace 対応サービス

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

Page 12: appengine ja night #10 Google AppEngine で作る Google Apps Marketplace 対応サービス

Google Apps MarketplaceからGoogle Apps に Product をインストールするとはどういうことか

Page 13: appengine ja night #10 Google AppEngine で作る Google Apps Marketplace 対応サービス

Google Apps MarketplaceからGoogle Apps に Product をインストール

Add it now ボタン

をクリックして …

Google Apps ドメイン名

を入力して GO

すると … Google Apps に遷移する

Page 14: appengine ja night #10 Google AppEngine で作る Google Apps Marketplace 対応サービス

Google Apps Marketplace 及びProduct の利用規約への同意

利用規約はProduct (製品情報)で設定する

Page 15: appengine ja night #10 Google AppEngine で作る Google Apps Marketplace 対応サービス

Product から Google Apps へのデータアクセスの許可

データアクセスの範囲と理由はApplication Manifestで定義する

Page 16: appengine ja night #10 Google AppEngine で作る Google Apps Marketplace 対応サービス

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= …

Page 17: appengine ja night #10 Google AppEngine で作る Google Apps Marketplace 対応サービス

Application Manifest とは何か

Page 18: appengine ja night #10 Google AppEngine で作る Google Apps Marketplace 対応サービス

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> <!–製品名 -->

Page 19: appengine ja night #10 Google AppEngine で作る Google Apps Marketplace 対応サービス

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

Page 20: appengine ja night #10 Google AppEngine で作る Google Apps Marketplace 対応サービス

Application Manifest 3/4OpenID承認ステップのスキップ

<Extension id="realm" type="openIdRealm">

<Url>http://opensocial-pages.appspot.com</Url>

</Extension>インストールした時点で許可したとみなして

スキップして表示しない

Page 21: appengine ja night #10 Google AppEngine で作る Google Apps Marketplace 対応サービス

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>

Page 22: appengine ja night #10 Google AppEngine で作る Google Apps Marketplace 対応サービス

Google Apps MarketplaceにProduct を掲載する手順

Page 23: appengine ja night #10 Google AppEngine で作る Google Apps Marketplace 対応サービス

Google Apps MarketplaceProduct の開発から公開までの流れ

Vendor (会社情報) とProduct (製品情報)の登録

Product の開発とテストVendor は公開前でもインストールできる

Google Marketplace への公開申請Google Checkout で 100 ドル支払い

Google Marketplace による審査結果は48時間以内にメールで通知

Google Marketplace の掲載開始誰でもインストールできる

Page 24: appengine ja night #10 Google AppEngine で作る Google Apps Marketplace 対応サービス

Vendor (会社情報)

• Company logo

• Vendor name

• Phone number

• Email address

• Home page URL

• Address line

• Town

• Zip/post code

• Country

• Vendor overview

Page 25: appengine ja night #10 Google AppEngine で作る Google Apps Marketplace 対応サービス

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

Page 26: appengine ja night #10 Google AppEngine で作る Google Apps Marketplace 対応サービス

OpenID Single-Sign On:Google OpenID Federated Login

Page 27: appengine ja night #10 Google AppEngine で作る Google Apps Marketplace 対応サービス

Authentication Options:(Experimental) Federated Login

Google AppEngineApplication Settings

Page 28: appengine ja night #10 Google AppEngine で作る Google Apps Marketplace 対応サービス

ログイン画面への誘導

UserService userService =UserServiceFactory.getUserService();

String loginUri = userService.createLoginURL("/", // ログイン後のリダイレクト先

"","n35.com", // Google Apps ドメイン名

new HashSet<String>() // 無効っぽい?

);response.sendRedirect(loginUri);

Page 29: appengine ja night #10 Google AppEngine で作る Google Apps Marketplace 対応サービス

ログアウト画面への誘導

UserService userService =

UserServiceFactory.getUserService();

String logoutUrl =

userService.createLogoutURL("/");

request.setAttribute("logoutUrl", logoutUrl);

Page 30: appengine ja night #10 Google AppEngine で作る Google Apps Marketplace 対応サービス

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();

[email protected]

user.getNickname(); // 名前は AX で取得できない?

[email protected]

Page 31: appengine ja night #10 Google AppEngine で作る Google Apps Marketplace 対応サービス

UserServiceで取得できる情報 2/2

UserService userService = UserServiceFactory.getUserService();

userService.isUserAdmin();

true // Google Apps の Administrator ではないです!

userService.isUserLoggedIn();

true

Page 32: appengine ja night #10 Google AppEngine で作る Google Apps Marketplace 対応サービス

2-legged OAuth for Data:Google Apps Provisioning API

Page 33: appengine ja night #10 Google AppEngine で作る Google Apps Marketplace 対応サービス

Google Data Java Client Library

Google Apps Provisioning API で必要なファイル

• gdata-core-1.0.jar

• gdata-client-1.0.jar

• gdata-appsforyourdomain-1.0.jar

Page 34: appengine ja night #10 Google AppEngine で作る Google Apps Marketplace 対応サービス

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 (会社情報)

Page 35: appengine ja night #10 Google AppEngine で作る Google Apps Marketplace 対応サービス

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();

Page 36: appengine ja night #10 Google AppEngine で作る Google Apps Marketplace 対応サービス

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");

Page 37: appengine ja night #10 Google AppEngine で作る Google Apps Marketplace 対応サービス

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");

Page 38: appengine ja night #10 Google AppEngine で作る Google Apps Marketplace 対応サービス

情報源

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/