Example: Username and Password
danger
Deprecated and may stop working: Snowflake recommends using External OAuth or Key Pair Authentication.
See our Authentication and MFA guidance.
Steps
- Create a connection using the standard Snowflake SDK
createConnection
method, but don’t callconnect
orconnectAsync
yet. - After creating the connection, pass it to the Promise Helper library’s
promisifyConnection
method. - On the promisified connection object, await the
connect
method.
Example Code: Username and Password
If you have Multi-Factor Authentication (MFA) enabled, this will send a confirmation request to the Duo app on your device, which you must approve to complete the connection.
import { promisifyConnection } from "snowflake-promise";
import snowflake from "snowflake-sdk";
// Create a Connection using the SDK’s `createConnection` and promisify it
const connection = promisifyConnection(
snowflake.createConnection({
account: account,
username: user,
password: password,
}),
);
// Connect to Snowflake
try {
await connection.connect();
console.log("Successfully connected to Snowflake.");
} catch (err) {
console.error("Unable to connect: " + err.message);
}