Composer gives the error "user is not authorized to access server"

Troubleshooting for a user authorization error in composer.

You successfully launch composer but when you try to run a command, the following error is given:
user is not authorized to access server

Cause and solution:

This is a problem that is common to several CLI programs; see Command line programs (like composer) give the error "user is not authorized to access server".