Resetting basic authentication credentials with AFNetworking

后端 未结 3 1202
花落未央
花落未央 2021-02-08 23:59

I am writing a REST client (with AFNetworking) and need the ability to trigger the creation of a new session within a single instance of an application.

In other words,

3条回答
  •  南笙
    南笙 (楼主)
    2021-02-09 00:46

    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.

提交回复
热议问题