Apple ID isn't working
There's several possible reasons for this. I've personally had it happen that the iCloud authentication servers just could not be reached for a while, so I was scratching my head for quite a bit until it all of a sudden worked...

Assuming that's not the case for you here, the first step to do would be to ensure that the phone is no longer associated with the apple id of your friend. For this your friend should go here, log in and ensure the device is not listed anymore (if it is, remove it). Something that I noticed is that this doesn't necessarily remove the device from "Find my iPhone" in iCloud, so your friend should probably also go to iCloud and verify (and possibly remove) it's gone there as well. Make sure to have them do so under "Find my iPhone" (or whatever it's called in English, I'm on the German equivalent atm) and in the "Settings".

Unfortunately I can't guarantee this does the trick, as said I've had weird sign in problems in the past as well, so this is just a hunch. In the end, you might have to contact the support if the problem persists.