Can login on Docker hub but not on command line

I can use my user name and password to login on the Docker Hub website, but when I try on the command line with “docker login” it fails. I have tried on both Linux and MacOS. I get

Get “https://registry-1.docker.io/v2/”: unauthorized: incorrect username or password