- Run SQL and use the SQL REST API (for example submitting statements and checking status)
- Work with warehouses, databases, and schemas your role can access
- Build internal tools, dashboards, and data workflows backed by Snowflake
Common use cases and example apps
How Snowflake connections work
- OAuth 2.0 (authorization code): You register a custom OAuth integration in Snowflake and enter the Account URL, Client ID, Client Secret, and Role in Lovable. You (or your admin) then complete sign-in with Snowflake to authorize the connection. Lovable stores the OAuth tokens and refreshes them automatically, so credentials never live in your app’s code.
- Role: The connection runs under a single Snowflake role that you configure. Administrator roles cannot be used; create a dedicated, least-privilege role instead (Step 2 below shows how).
- Gateway: API requests are proxied through Lovable’s connector gateway, which manages tokens. See Gateway-based connectors for limits.
How to connect Snowflake
Who can create Snowflake connections depends on your plan and workspace settings. On Enterprise plans, app + chat connectors are effectively disabled at first: Who can create connections and clients defaults to No one until an admin changes it. You can create multiple Snowflake connections using different accounts or roles, which is useful for separating development and production data. When the connection is created, you can link it to the projects where you want to use it. Anyone building in a project can ask Lovable in chat to link their project to it. The steps below can create everything from scratch, but you do not have to start from a blank slate: each step opens with the criteria an existing piece must meet, so verify and skip the creation SQL where yours already passes.Prerequisites
Before connecting Snowflake, make sure you have:- A Snowflake account, and a user with the
ACCOUNTADMINrole (or the globalCREATE INTEGRATIONprivilege) to create the OAuth security integration and read its client secret - Privileges to create a role and grant it access to your data:
USERADMINto create the role, andSECURITYADMINto run the grants (its globalMANAGE GRANTSprivilege covers objects it does not own, and the future grants in Step 2 require it) - A dedicated, non-personal Snowflake user to authorize the connection. Using a dedicated user rather than someone’s own account means the connection stays active if the person who set it up leaves the company. This user must hold the dedicated role and must be able to complete a browser sign-in, so keep it at
TYPE = PERSON. ATYPE = SERVICEuser cannot authorize the connection: it can sign in with neither a password nor SAML SSO, and Snowflake OAuth only offers the authorization code flow, which needs an interactive login - Permission to create connections in your Lovable workspace (see Who can create connections and clients)
Step 1: Find your account URL
Lovable needs your account URL in the formhttps://<orgname>-<account_name>.snowflakecomputing.com, with no trailing slash or path.
Open the account selector in Snowsight
Copy the account URL
Step 2: Create a least-privilege role
Snowflake blocksACCOUNTADMIN, SECURITYADMIN, ORGADMIN, and GLOBALORGADMIN from OAuth sessions by default, and Lovable additionally rejects ACCOUNTADMIN and SECURITYADMIN in the connection form. This is a feature, not a limitation: create a dedicated role that can see only the data your app needs.
Reuse an existing role instead?
Reuse an existing role instead?
- It is none of the blocked roles above, not on your integration’s
BLOCKED_ROLES_LIST, and present in itsALLOWED_ROLES_LISTif one is set (DESC SECURITY INTEGRATION). - It is granted to the user who will authorize the connection (
SHOW GRANTS TO USER <user>). - It has
USAGEon a warehouse plus the data grants your app needs (SHOW GRANTS TO ROLE <role>).
USE ROLE stays in effect for the rest of your worksheet session.
Create the role
Grant the role a warehouse
SECURITYADMIN: granting on a warehouse you do not own requires the global MANAGE GRANTS privilege, which only SECURITYADMIN and ACCOUNTADMIN hold.Grant access to your data
SECURITYADMIN: in a standard schema, the future grants at the end require the global MANAGE GRANTS privilege, so owning the database is not enough.Read-only example:INSERT, UPDATE, or DELETE grants only if your app writes data.Grant the role to the authorizing user
SELECT CURRENT_USER();. An unquoted Snowflake identifier can only contain letters, digits, underscores, and dollar signs, so if the username contains anything else, double-quote it and match the case exactly. An email-style username needs quoting twice over: the @ is the obvious one, but the . forces it too and is easy to miss (GRANT ROLE LOVABLE_ROLE TO USER "jane.doe@company.com";).Switch back to USERADMIN, which owns the role it created in the first step and can therefore grant it. If you reused an existing role that USERADMIN does not own, run this statement as SECURITYADMIN instead:Step 3: Create the OAuth security integration
This is the OAuth client Lovable authenticates against. Creating it requiresACCOUNTADMIN or the global CREATE INTEGRATION privilege. See Configure Snowflake OAuth for custom clients in the Snowflake docs. Already have an integration? Jump to the reuse checks below.
Already have an OAuth integration?
Already have an OAuth integration?
OAUTH_CLIENT = CUSTOM) with OAUTH_CLIENT_TYPE = CONFIDENTIAL, it is enabled, and Lovable’s callback is either its OAUTH_REDIRECT_URI or one of its OAUTH_ALTERNATE_REDIRECT_URIS. One hard limit:OAUTH_CLIENT_TYPEcannot be changed after creation. An existingPUBLICclient must be recreated asCONFIDENTIAL.
OAUTH_ALTERNATE_REDIRECT_URIS. Create a separate integration per application anyway: it keeps each tool’s allowed roles, secret rotation, and revocation independent of the others.Everything else is fixable in place on an integration dedicated to Lovable:OAUTH_CLIENT_TYPE = 'CONFIDENTIAL': Lovable stores the client secret server-side and can use a confidential client, which is stronger than a public one.OAUTH_REDIRECT_URI: must exactly match the callback Lovable uses. The Lovable connection form shows this value under Redirect URI with a copy button, so you can copy it from there.OAUTH_ISSUE_REFRESH_TOKENS = TRUEandOAUTH_REFRESH_TOKEN_VALIDITY = 7776000: Snowflake access tokens are short-lived, so Lovable refreshes them in the background. Both values are already Snowflake’s defaults for a custom client, so these two lines change nothing on a fresh integration; set them explicitly anyway so the connector does not silently inherit a shorter validity from an integration someone edited earlier. 7776000 seconds (90 days) is also the maximum, and you reconnect in Lovable when the refresh token expires, so this keeps reconnects to at most once per quarter.OAUTH_ENFORCE_PKCE = TRUE: Lovable always sends a PKCE code challenge, so you can enforce it. This protects the flow against authorization code interception.ALLOWED_ROLES_LIST = ('LOVABLE_ROLE'): every role not listed is implicitly blocked, so this integration can only ever mint sessions for the connector role. Leaked client credentials cannot be parlayed into a broader session, and repointing the Lovable connection at a more privileged role fails at the authorize step until whoever controls the integration updates this list first.
OAUTH_USE_SECONDARY_ROLES at its default (NONE) so sessions are limited to the single role you configured and cannot pick up extra privileges from the authorizing user’s secondary roles.Step 4: Retrieve the client ID and secret
Still asACCOUNTADMIN, read the generated credentials:
oauth_client_id, oauth_client_secret, and oauth_client_secret_2. Copy oauth_client_id and oauth_client_secret (either secret works; two exist so you can rotate them without downtime). The function can be re-run at any time, so a lost secret never requires recreating the integration.
Step 5: Connect Snowflake in Lovable
Open Snowflake in Connectors
Add a connection
Name the connection
Snowflake Prod). This name is only used inside Lovable to identify the connection.Enter the connection details
- Account URL: the URL from Step 1.
- Client ID and Client Secret: the values from Step 4.
- Role:
LOVABLE_ROLE. Enter it in uppercase, exactly as it appears inSHOW ROLES. The role name is passed to Snowflake case-sensitively as the OAuth scope.
Choose who can use this connection
- Only you (default): leave the access list as is; only you can use the connection and its associated data.
- Invite specific people: add workspace members by email; only you and the people you add can use the connection and its associated data.
- Invite entire workspace: click Invite entire workspace to make the connection available to everyone in your Lovable workspace.
Connect to Snowflake and authorize
LOVABLE_ROLE (from Step 2), review the requested role, and click Allow.Verify and use the connection
The first successful query is what proves the role can actually reach a warehouse and your data, so run one right after you connect. Link the connection to a project and ask Lovable in chat to query your data, for example:- Queries that need compute must run on a warehouse. Tell Lovable which warehouse to use (the SQL API accepts a
warehouseparameter per statement), or set a default warehouse on the authorizing user. - If the query fails, the connection itself is fine and the role is missing a warehouse or a grant. Go back to Step 2 and check
SHOW GRANTS TO ROLE LOVABLE_ROLE;.
Best practices
- One connection per environment: create separate integrations, roles, and connections for development and production data.
- Keep the role read-only unless the app genuinely writes data, and scope grants to specific schemas rather than whole databases.
- For production apps, use a dedicated warehouse with a resource monitor to cap unexpected spend.
- Authorize with a dedicated user rather than a personal login. If the authorizing user is disabled, the connection stops working until someone reconnects.
- Rotate the client secret periodically using the second secret slot, then update the connection in Lovable.
- Changing the connection’s role later? Add the new role to the integration’s
ALLOWED_ROLES_LISTbefore reconnecting. - Expect to reconnect when the refresh token expires (at most every 90 days with the settings above).
Limitations
- Scopes and roles are determined by your Snowflake OAuth integration and the role you configure; the app cannot exceed those permissions.
- Per-user Snowflake login is not provided by this connector. Each connection represents a shared authorization for the workspace connection. If you need each end user to sign in with their own Snowflake account and query under their own role, use the Snowflake app user connector.
- Gateway limits apply as described in Gateway-based connectors.
Manage your connection
Connections are managed from Connectors: select , then open the connection.- Unlink projects to remove access from specific projects while keeping the connection available for others. See Unlink projects from a connection for the steps.
- Delete the connection to remove it from the workspace entirely. Deleting is permanent. It removes the credentials from all linked projects, and app features that use stop working until a new connection is added. See Delete a connection for the steps and who can delete.
Troubleshooting
Redirect URI mismatch
Redirect URI mismatch
OAUTH_REDIRECT_URI or one of its OAUTH_ALTERNATE_REDIRECT_URIS. A common cause is reusing an integration created for another tool; create a Lovable-dedicated one instead. Otherwise fix it with ALTER SECURITY INTEGRATION LOVABLE_OAUTH SET OAUTH_REDIRECT_URI = '...';.The connection works, but queries fail
The connection works, but queries fail
warehouse in the statement or set a user default) or a missing grant on the queried object.Reconnecting every day
Reconnecting every day
OAUTH_REFRESH_TOKEN_VALIDITY, because Snowflake defaults it to the 90 day maximum. Check the current value with DESC SECURITY INTEGRATION LOVABLE_OAUTH;. If it is at or near the minimum for a custom client (86400, one day), raise it with ALTER SECURITY INTEGRATION LOVABLE_OAUTH SET OAUTH_REFRESH_TOKEN_VALIDITY = 7776000; and reconnect once more.The connection stopped working after weeks
The connection stopped working after weeks