I noticed the you haven't recieved a response to your post just yet. If you could answer the following questions, it may help others in the Apple Support Communities get you to a solution:
- What verification code do you mean: Is it from two-factor authentication? Two-step verification? Something else?
- What happens when you try: Do you not get the code on your iPhone? Do you not know where to enter the code? Are you able to enter the code, but it is not accepted?
- What macOS version is installed on your iMac? You can find this information by selecting the Apple menu > About This Mac. Please provide the entire macOS name and version number (example: macOS High Sierra 10.3.3)