0

Android の Eclipse で行っているのと同じように、Titanium で作成されたアプリ内に Windows Azure サービスを統合したいと考えています。私はチタンを扱う初心者です。始めるのに役立つリンクをいくつか提供してください。

4

3 に答える 3

1

これらを見つけました: http://developer.appcelerator.com/question/149494/using-titanium-httpclient-to-access-windows-azure-mobile-services-rest-api

これは JavaScript ライブラリなので、役立つはずです。少し古いかもしれませんが。 http://azureblobstoragejs.codeplex.com/

于 2013-07-29T13:31:37.883 に答える
0

編集:

Windows Azure モバイル サービス用の Titanium SDK を作成しました。ここで確認してください: https://github.com/rfaisal/tiny-azuresdk-titanium

元の回答:

最初に facebook にログインして access_token を取得します (authorization_grant と呼びましょう):

var fb=require('facebook');
fb.appid = 000000000000000; //replace this with your facebook app id
fb.permissions = ['email']; // add or remove permissions
fb.addEventListener('login', function(e) {
    if (e.success) {
        Ti.API.info('authorization_grant: '+fb.getAccessToken()); // prints to console, save for future use
    }
});
fb.authorize();

次に、authorization_grant から access_token (facebook ではなく azure) を取得します。

var authorization_grant = 'CAAHn34BO0R0BABtJyxdrZCQzakdmgJZBoQa0U...'; //saved from previous step
var xhr = Titanium.Network.createHTTPClient();
xhr.setTimeout(30000);
xhr.onload=function() {
    Ti.API.info('access_token: '+JSON.parse(this.responseText).authenticationToken); // save this for requesting protected resource
};
xhr.onerror= function() {
    Ti.API.info('Auth Failure response: '+this.responseText);
};
xhr.open('POST', 'https://my_resource_auth_server.azure-mobile.net/login/facebook');
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Accept", "application/json");
xhr.send({
    "access_token" : authorization_grant
});

最後に、access_token によって保護されたリソースを取得します。

var access_token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCIsI...'; //saved from previous step
var xhr = Titanium.Network.createHTTPClient();
xhr.setTimeout(30000);
xhr.onload=function() {
    Ti.API.info('Protected Resource: '+this.responseText);
};
xhr.onerror= function() {
    Ti.API.info('Error response: '+this.responseText);
};
xhr.open('GET', 'https://my_resource_auth_server.azure-mobile.net/api/some_resource');
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Accept", "application/json");
xhr.setRequestHeader("X-ZUMO-AUTH", access_token); // this is the magic line
xhr.send();

アプリケーション レベルのアクセスが必要なリソースを取得するには、X-ZUMO-APPLICATION というヘッダーを追加し、Azure Web サイトから取得したアプリケーション キーを渡します。同様に、管理者レベルのアクセスが必要なリソースにアクセスするには、Azure Web サイトから取得したモバイル サービス マスター キーを X-ZUMO-MASTER ヘッダーとして渡します。

ここでフォローされている oAuth フロー: ここに画像の説明を入力

最初に公開された記事: https://rfaisalblog.wordpress.com/2014/03/01/oauth-flow-for-mobile-apps-with-an-external-identity-server/

于 2014-03-01T22:26:47.790 に答える