2

Token based authentication is one of the security authentication method we follow.

But In case of authentication setting up the header with auth token do the job.But How to manage the webservices with refresh mechanism?As the token expire we have to deal with a web service and create a new one.So in a bigger app with lots of webservice interaction how can we manage?

Should we have to work on the failure mechanism in every webservice checking if the token fails, get new token and then call the option again?

In framework like AFNetworking or ASIHttp is this handled or we have to deal with code ourselves.If so how can or how should we deal with it?

Get Token -> Store in header -> Call Webservices -> Success

Call weservice -> auth expire failure -> get new Token -> call Webservice again -> Success : How to handle this?

4

1 回答 1

0

您需要将从 WS 获得的令牌保存到 NSUserDefaults 中,并以令牌为键。因此,每当您获得新令牌时,您只需要更新 UserDefaults 并从 UserDefaults 获取更新的令牌以用于下一个 WS。

于 2013-07-26T06:38:14.853 回答