Is it possible to reset NSURLConnection after providing credentials?

I call a REST service that requires basic auth and I reply to the didReceiveAuthenticationChallenge OK delegate

    NSURLCredential *credential = [[NSURLCredential alloc] initWithUser:self.user password:self.password persistence:NSURLCredentialPersistenceForSession];
    [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge];
    [credential release];

The credentials are valid for the session, but I would like my application to be able to switch between servers, and so I need to “reset” the session so that it again requests a call.

I can, of course, try not to store the credentials for the session and provide them for every call, but this does not seem to be a good idea.

Any ideas would be appreciated!

+3
source share

Source: https://habr.com/ru/post/1740401/


All Articles