Ruby on rails 如何对钛客户机进行身份验证
我有一个Rails应用程序,带有用于用户身份验证的Desive gem 在Tianium应用程序上对用户进行身份验证的最佳方式是什么?我希望用户在Tianium应用程序上输入他的凭证,然后rails应用程序使用Desive检查登录/密码Ruby on rails 如何对钛客户机进行身份验证,ruby-on-rails,rest,authentication,devise,titanium,Ruby On Rails,Rest,Authentication,Devise,Titanium,我有一个Rails应用程序,带有用于用户身份验证的Desive gem 在Tianium应用程序上对用户进行身份验证的最佳方式是什么?我希望用户在Tianium应用程序上输入他的凭证,然后rails应用程序使用Desive检查登录/密码 应用程序之间的通信通过REST接口完成,我使用自定义HTTP头传输凭据。假设您有一个这样的视图,它接受用户名和密码: <Alloy> <View layout="vertical" height="Ti.UI.SIZE" width="
应用程序之间的通信通过REST接口完成,我使用自定义HTTP头传输凭据。假设您有一个这样的视图,它接受用户名和密码:
<Alloy>
<View layout="vertical" height="Ti.UI.SIZE" width="80%" top="25%">
<TextField id="username" height="40dp" width="60%"/>
<TextField id="pwd" height="40dp" width="60%"/>
<Button id="loginBtn" width="80%"/>
</View>
</Alloy>
您需要提供有关自定义http标头的信息。这可以起作用,但它不会传递标头中的凭据,这是他在原始问题中所述的。遗漏了该部分,更新了我的答案,反映了他提供的信息。
var xhr = Titanium.Network.createHTTPClient({
timeout : 2000,
onload : function() {
// Successful return, do something with it
var retval = this.responseText;
},
onerror : function() {
Ti.API.error(this.responseText);
}
});
xhr.open('POST',"http://your-web-service");
// Set headers here, _after_ opening
var userinfo = {username : $.username.value, pwd : $.pwd.value};
xhr.setRequestHeader("Authorization_Custom_Header", "Assemble your header here or use OAuth");
xhr.send();