in keyrings/gauth.py [0:0]
def get_password(self,service,username):
url = urlparse(service)
if url.hostname is None or not url.hostname.endswith(".pkg.dev"):
return
#trying application default credentials otherwise fall back to gcloud credentials command
try:
CREDENTIAL_SCOPES =["https://www.googleapis.com/auth/cloud-platform"]
credentials, project_id = google.auth.default(scopes=CREDENTIAL_SCOPES)
credentials.refresh(requests.Request())
return credentials.token
except Exception as e:
logging.warning("Failed to retrieve Application Default Credentials: {0}".format(e))
try:
credentials = get_gcloud_credential()
return credentials
except Exception as e:
logging.warning("Failed to retrieve credentials from gcloud: {0}".format(e))
logging.warning("Artifact Registry PyPI Keyring: No credentials could be found.")
raise Exception("Failed to find credentials, Please run: `gcloud auth application-default login or export GOOGLE_APPLICATION_CREDENTIALS=<path/to/service/account/key>`")