サーバー側の Web サービス API を保護するにはどうすればよいですか? 何かツールはありますか?
OAuth はあなたのニーズに対して過剰かもしれません。そのような強力な (そして複雑な) 標準を本当に使用する必要があるかどうかを確認してください。
使用できる PHP サーバー側ソフトウェアの 2 つの例:
ローカル ストレージを使用してキー/トークンを保存できますか?
はい!クライアント側でトークンを取得するには、OAuth 2.0 の暗黙的な付与フローを使用する必要があることに注意してください。
クライアント側で使用できる phonegap セキュリティ ツールは何ですか?
ChildBrowser は、認証プロセス用に別のブラウザ ウィンドウを開くプラグインです。
OAuth 2.0 を実行できる JavaScript ライブラリ JSO を作成しました。他のライブラリも存在します。
この場合、どうすれば OAUTH を使用できますか?
Phonegap および ChildBrowser での JSO の使用
JSO を使用して、ハイブリッド環境のモバイル デバイスで実行されている WebApps で OAuth 2.0 承認を実行することは、JSO の重要な展開シナリオです。
ここでは、iOS 用の Phonegap を使用して JSO をセットアップし、Google で OAuth 2.0 を構成するための詳細な手順を示します。Facebook やその他の OAuth プロバイダーでも使用できます。
準備
セットアップアプリ
新しいアプリを作成するには
./create /Users/andreas/Sites/cordovatest no.erlang.test "CordovaJSOTest"
ChildBrowser をインストールする
オリジナルの ChildBrowser プラグインはこちらから入手できます。
ただし、Cordova 2.0 には対応していません。代わりに、Cordova 2.0 で動作するはずの ChildBrowser の次のフォークを使用できます。
これらのファイルをコピーする必要があります。
XCode の Plugins フォルダーにドラッグ アンド ドロップして、WebApp プロジェクト エリアに移動します。
Resources/Cordova.plist
ここで、WebApp プロジェクト エリアにあるファイルを編集する必要があります。
このファイルでは、'*' を含む 1 つの配列エントリを ExternalHosts に追加し、2 つのエントリを Plugins に追加する必要があります。
- ChildBrowser -> ChildBrowser.js
- ChildBrowserCommand -> ChildBrowserCommand
スクリーンショットに見られるように。

(出典: erlang.no )
ChildBrowser を使用して WebApp をセットアップする
OAuth に移る前に、ChildBrowser が機能することをテストして確認することをお勧めします。
index.html
ファイルでこれを試し、シミュレーターを使用して確認します。
<script type="text/javascript" charset="utf-8" src="cordova-2.0.0.js"></script>
<script type="text/javascript" charset="utf-8" src="ChildBrowser.js"></script>
<script type="text/javascript">
var deviceready = function() {
if(window.plugins.childBrowser == null) {
ChildBrowser.install();
}
window.plugins.childBrowser.showWebPage("http://google.com");
};
document.addEventListener('deviceready', this.deviceready, false);
</script>
JSOの設定
JSO の最新バージョンをダウンロードします。
JSO に関するドキュメントもここで入手できます。
コールバック URL はどこかを指している必要があります。1 つの方法は、コールバック HTML ページをどこかに配置することです。信頼できるホストであっても、場所は問題ではありません。そしてそこにかなり空白のページを置きます:
<!doctype html>
<html>
<head>
<title>OAuth Callback endpoint</title>
<meta charset="utf-8" />
</head>
<body>
Processing OAuth response...
</body>
</html>
次に、アプリケーションのインデックス ページをセットアップします。これが実際の例です:
<script type="text/javascript" charset="utf-8" src="cordova-2.0.0.js"></script>
<script type="text/javascript" charset="utf-8" src="ChildBrowser.js"></script>
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="jso/jso.js"></script>
<script type="text/javascript">
var deviceready = function() {
var debug = true;
/*
* Setup and install the ChildBrowser plugin to Phongap/Cordova.
*/
if(window.plugins.childBrowser == null) {
ChildBrowser.install();
}
// Use ChildBrowser instead of redirecting the main page.
jso_registerRedirectHandler(window.plugins.childBrowser.showWebPage);
/*
* Register a handler on the childbrowser that detects redirects and
* lets JSO to detect incomming OAuth responses and deal with the content.
*/
window.plugins.childBrowser.onLocationChange = function(url){
url = decodeURIComponent(url);
console.log("Checking location: " + url);
jso_checkfortoken('facebook', url, function() {
console.log("Closing child browser, because a valid response was detected.");
window.plugins.childBrowser.close();
});
};
/*
* Configure the OAuth providers to use.
*/
jso_configure({
"facebook": {
client_id: "myclientid",
redirect_uri: "https://myhost.org/callback.html",
authorization: "https://www.facebook.com/dialog/oauth",
presenttoken: "qs"
}
}, {"debug": debug});
// For debugging purposes you can wipe existing cached tokens...
// jso_wipe();
// jso_dump displays a list of cached tokens using console.log if debugging is enabled.
jso_dump();
// Perform the protected OAuth calls.
$.oajax({
url: "https://graph.facebook.com/me/home",
jso_provider: "facebook",
jso_scopes: ["read_stream"],
jso_allowia: true,
dataType: 'json',
success: function(data) {
console.log("Response (facebook):");
console.log(data);
}
});
};
document.addEventListener('deviceready', this.deviceready, false);
</script>