I've been trying to connect to Snowflake using their Golang driver. Below you'll find my code:
config := gosnowflake.Config{
Account: fmt.Sprintf("%s-%s", organization, account),
User: username,
Password: password,
Database: database,
Schema: schema,
Warehouse: warehouse,
}
connStr, err := gosnowflake.DSN(&config)
if err != nil {
panic(err)
}
db, err := sql.Open("snowflake", connStr)
if err != nil {
panic(err)
}
db.PingContext(ctx)
The problem I'm having is that every command I try to send to Snowflake after connecting returns the following error:
gosnowflake.(*defaultLogger).Errorln Authentication FAILED
If I change the account to be fmt.Sprintf("%s.%s", organization, account)
, this error goes away but, if I try to query with the connection, I get:
x509: certificate is valid for *.us-west-2.snowflakecomputing.com, *.us-west-2.aws.snowflakecomputing.com, *.global.snowflakecomputing.com, *.snowflakecomputing.com, *.prod1.us-west-2.aws.snowflakecomputing.com, *.prod2.us-west-2.aws.snowflakecomputing.com, not {MY_ORG_ID}.{MY_ACCT_ID}.snowflakecomputing.com.
According to this and this, the account identifier should be equal to {ORGANIZATION_NAME}-{ACCOUNT_NAME}
, which mine is. Furthermore, I have used the SHOW ORGANIZATION ACCOUNTS command to verify that the organization name and account name are correct.
CodePudding user response:
Can you check if the account locator is in correct format https://docs.snowflake.com/en/user-guide/admin-account-identifier.html#account-name
CodePudding user response:
I found the issue. The database and associated schemas were owned by the ACCOUNTADMIN role, which the associated user did not have. I transferred ownership of these to the SYSADMIN role, allowing the user to have access.