It depends on the nature of your contact with the officer. There are three levels of contact we have with the public: consensual contacts, detentions and arrests.
A consensual contact is defined as a voluntary interaction between an officer and a member of the community. In this type of contact, an officer can request to see your identification, and you can refuse.
If you are detained, which means we have reasonable suspicion that a crime has occurred or is in progress, you can be compelled to provide your identification as part of the detention.
If you are arrested, you can be compelled to provide your identification.