Resetting basic authentication credentials with AFNetworking

旧街凉风 提交于 2019-12-03 07:02:50

Use AFHTTPClient (see the API client in the example project).

Credentials can be set with -setAuthorizationHeaderWithUsername:password:. Each request created from that HTTP client will have an Authorization HTTP header, kind of like a browser session.

When the user logs out, or you want to clear credentials, do -clearAuthorizationHeader.

Even simpler.

[request setHTTPShouldHandleCookies:NO];

Rest calls as far as I know are not session based. Meaning you can't simulate an authentication and log-out session in a particular call. What I think you can do is to Authenticate for every call made to the end point. So for every end point(Method), you authenticate the caller. I think that's the bets you can do in a restful system.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!