def _get_gcp_credentials()

in modular_sdk/services/impl/maestro_credentials_service.py [0:0]


    def _get_gcp_credentials(self, application: Application,
                             tenant: Optional[Tenant] = None,
                             ) -> Optional[GOOGLECredentials]:
        if not application.secret:
            _LOG.warning(f'Application {application.application_id} does not '
                         f'contain secret')
            return
        secret = self._ssm_service.get_parameter(application.secret)
        if not secret:
            _LOG.warning(f'Secret {application.secret} exists in application,'
                         f' but not in SSM')
            return
        if not isinstance(secret, dict):  # it must be dict
            return
        meta = GCPServiceAccountApplicationMeta.from_dict(
            application.meta.as_dict()
        )
        project_id = meta.adminProjectId
        secret.setdefault(MA_SSM_PROJECT_ID, project_id)  # just in case
        with tempfile.NamedTemporaryFile('w', delete=False) as fp:
            json.dump(secret, fp)
        return GOOGLECredentials(
            GOOGLE_APPLICATION_CREDENTIALS=Path(fp.name),
            CLOUDSDK_CORE_PROJECT=project_id  # or secret['project_id'] ?
        )