For a used iPhone, ask the original owner to enter their credentials, sign out of iCloud ... Apple Account on iOS 11 or later ...
Unfortunately, the only way to reliably unlock ... an iPhone still in your possession. Obviously, you’ll need your Apple ID details to use this method, but you may actually know your iCloud ...