The 401 error code indicates a problem with the authentication credentials.
To make sure you have a valid token OAuth 2 token, run the following:
$ gcloud auth print-access-token
Verify that the token is supplied in the Authorization HTTP header. It should look like this:
Authorization: Bearer {TOKEN}
If the error persists, try to refresh the token using step 1, as the tokens have a limited time.
Additional Reference stackoverflow.com/a/48734637/14072498