If you receive the error, "User not in environment" when deploying via the API, this is typically due to using an API token for a user who has not yet proven their Snowflake OAuth authentication for the environment and is an easy fix.
With Snowflake OAuth connectivity, while it can be configured by a single Admin/individual user for a Workspace and/or Environment, each individual user who wishes to connect via it will have to prove their authorization to use the connection individually. In other words, the OAuth authentication channel is opened via a shared trust that each individual who wishes to leverage it must prove their access to.
The "User not in environment" error is received during deployment via the API when the user whose API token is being used has not yet proven this access. This is corrected via the following steps:
- The affected user should login to the Coalesce UI.
- Launch the main workspace that contains the Environment you are deploying to.
- Open the Build Settings, and navigate to Environments
- Edit the Environment you are deploying to
- Navigate to OAuth Settings and confirm they are configured. Do not change them if so; configure them if not.
- Navigate to User Credentials and confirm your authentication type is set to Snowflake OAuth, and your Role and Warehouse are filled in if your user does not have a default role and/or warehouse.
- Click Authenticate to prove you have access via the OAuth connection.
After completing the above, your "User not in environment" error should resolve itself when you retry deploying via the API.