The 4th Amendment of the Constitution protects against unreasonable searches. However, border searches are an exception and border agents are able to search you and your belongings to a certain extent.
Border agents are permitted to ask for passwords to unlock your laptop and cell phones. You may refuse to provide the password, but that can lead to other problems such as additional questioning, seizing your devices, and making copies of the content. If you chose to provide the password to unlock your laptop or phone and you have apps with automatic logins, the agents can look through your app accounts.
Although refusing to provide passwords to your devices can lead to other problems, you can ensure that you are protected. If a border agent orders you to provide a password to your social media account, state that you are complying under protest and that you do not consent to the search. By saying this, you have the right to challenge the border agent’s actions if you wish. Additionally, you can tell the border agents that they are welcome to look at the public information on your social media and you will provide a password once a warrant is issued.