I've finally found some more time to fiddle with this problem. The problem appears to be related to the fact that I'm using one script that grabs data from three different Wikipedias (English, Norwegian, and Swedish) with three different accounts[1]. Doing them in order the script correctly logs in to each one, and when it later returns to the first one it seems to think it's logged in. Looking at the cookie info I see that the centralAuth info is correct for the Swedish account, not for the English, and there are cookies for user ID and username for each of the three langauges. So if the script thinks it's logged in to English Wikipedia and sends the request, the API will correctly notice that the info isn't consistent and throw the error.
Is my reasoning correct here? Is there something I can do on my end to force a login every time, or should I instead write my scripts so they run separately for each account?
Footnotes: 1: Once upon a time it seemed like a great idea... 2: Need to be logged in to read the patrolled flag, from what I've been able to figure out.
Cheers, Morten