简体   繁体   English

在多个Web服务之间保留登录数据的最佳方法是什么?

[英]What is the best way to persist login data between multiple web services?

I am writing an application that consumes several web services. 我正在编写一个使用多个Web服务的应用程序。 There is not a authentication system in place per say however each web service requires a login/password. 每句话都没有一个身份验证系统,但是每个Web服务都需要一个登录名/密码。

So in my application when a user first opens the app, a login/password box prompts them to enter that information. 因此,在我的应用程序中,当用户首次打开应用程序时,登录/密码框会提示他们输入该信息。 Once entered, that same login/password needs to persist for all the other web service calls. 输入后,所有其他Web服务调用都必须保留相同的登录名/密码。 What is the best/logical way to persist this information during the session? 在会话期间保留此信息的最佳/逻辑方法是什么?

your thoughts would be appreciated. 您的想法将不胜感激。

Thanks 谢谢

NSUserDefaults would be a good place to start. NSUserDefaults将是一个不错的起点。

I would also recommend not storing credentials per se, but instead storing the tokens that the web services send back if they support it. 我还建议不要本身存储凭据,而是存储Web服务在支持的情况下发回的令牌。

An example are Facebook's APIs. 一个例子是Facebook的API。 You can have a user login, but you only need to store two pieces of information, an access token and expiration date in order to continue making calls to the API "as" that user. 您可以具有用户登录名,但是您只需要存储两条信息,即访问令牌和到期日期,即可继续以该用户身份“以”身份调用API。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM