// Returns an authorized API client by discovering the Cloud IoT Core API with // the provided API key. const getClient = async () => { const authClient = await google.auth.getClient({ scopes: ['https://www.googleapis.com/auth/cloud-platform'], }); const discoveryUrl = `${DISCOVERY_API}?version=${API_VERSION}`; google.options({ auth: authClient, }); try { return google.discoverAPI(discoveryUrl); } catch (err) { console.log('Error during API discovery.', err); } }
// [END healthcare_export_dicom_instance_gcs] // Returns an authorized API client by discovering the Healthcare API with // the provided API key. // [START healthcare_get_client] function getClient(apiKey, serviceAccountJson, cb) { const API_VERSION = 'v1alpha'; const DISCOVERY_API = 'https://healthcare.googleapis.com/$discovery/rest'; google.auth .getClient({scopes: ['https://www.googleapis.com/auth/cloud-platform']}) .then(authClient => { const discoveryUrl = `${DISCOVERY_API}?labels=CHC_ALPHA&version=${API_VERSION}&key=${apiKey}`; google.options({auth: authClient}); google .discoverAPI(discoveryUrl) .then(client => { cb(client); }) .catch(err => { console.error(err); }); }); }
}); google.discoverAPI(discoveryUrl).then((client, err) => { if (err) { console.log('Error during API discovery', err);
// Returns an authorized API client by discovering the Cloud IoT Core API with // the provided API key. const getClient = async serviceAccountJson => { // the getClient method looks for the GCLOUD_PROJECT and GOOGLE_APPLICATION_CREDENTIALS // environment variables if serviceAccountJson is not passed in const authClient = await google.auth.getClient({ keyFilename: serviceAccountJson, scopes: ['https://www.googleapis.com/auth/cloud-platform'], }); const discoveryUrl = `${DISCOVERY_API}?version=${API_VERSION}`; google.options({ auth: authClient, }); try { return google.discoverAPI(discoveryUrl); } catch (err) { console.log('Error during API discovery.', err); } }
// [END healthcare_patch_hl7v2_store] // Returns an authorized API client by discovering the Healthcare API with // the provided API key. // [START healthcare_get_client] function getClient(apiKey, serviceAccountJson, cb) { const API_VERSION = 'v1alpha'; const DISCOVERY_API = 'https://healthcare.googleapis.com/$discovery/rest'; google.auth .getClient({scopes: ['https://www.googleapis.com/auth/cloud-platform']}) .then(authClient => { const discoveryUrl = `${DISCOVERY_API}?labels=CHC_ALPHA&version=${API_VERSION}&key=${apiKey}`; google.options({auth: authClient}); google .discoverAPI(discoveryUrl) .then(client => { cb(client); }) .catch(err => { console.error(err); }); }); }
// [END healthcare_patch_hl7v2_message] // Returns an authorized API client by discovering the Healthcare API with // the provided API key. // [START healthcare_get_client] function getClient(apiKey, serviceAccountJson, cb) { const API_VERSION = 'v1alpha'; const DISCOVERY_API = 'https://healthcare.googleapis.com/$discovery/rest'; google.auth .getClient({scopes: ['https://www.googleapis.com/auth/cloud-platform']}) .then(authClient => { const discoveryUrl = `${DISCOVERY_API}?labels=CHC_ALPHA&version=${API_VERSION}&key=${apiKey}`; google.options({auth: authClient}); google .discoverAPI(discoveryUrl) .then(client => { cb(client); }) .catch(err => { console.error(err); }); }); }
// [END healthcare_get_fhir_store_metadata] // Returns an authorized API client by discovering the Healthcare API with // the provided API key. // [START healthcare_get_client] function getClient(apiKey, serviceAccountJson, cb) { const API_VERSION = 'v1alpha'; const DISCOVERY_API = 'https://healthcare.googleapis.com/$discovery/rest'; google.auth .getClient({scopes: ['https://www.googleapis.com/auth/cloud-platform']}) .then(authClient => { const discoveryUrl = `${DISCOVERY_API}?labels=CHC_ALPHA&version=${API_VERSION}&key=${apiKey}`; google.options({auth: authClient}); google .discoverAPI(discoveryUrl) .then(client => { cb(client); }) .catch(err => { console.error(err); }); }); }