In Terry, the court said that the "scope of the search must be 'strictly tied to and justified by' the circumstances which rendered its initiation permissible", and "The sole justification of the search ... is the protection of the police officer and others nearby, and it must therefore be confined in scope to an intrusion reasonably designed to discover guns, knives, clubs, or other hidden instruments for the assault of the police officer". McFadden "patted down the outer clothing of petitioner and his two companions. He did not place his hands in their pockets or under the outer surface of their garments until he had felt weapons, and then he merely reached for and removed the guns... Officer McFadden confined his search strictly to what was minimally necessary to learn whether the men were armed and to disarm them once he discovered the weapons. He did not conduct a general exploratory search for whatever evidence of criminal activity he might find".
The search, as you describe it, is plainly an unlawful search of the person for the purpose of overcoming the person's lawful refusal to provide ID.