ALTER EXTERNAL CONSUMER … ADD PROGRAMMATIC ACCESS TOKEN (PAT)¶
Creates a Programmatic Access Token (PAT) for an external consumer. The token is used by the external consumer to authenticate with an Iceberg REST Catalog client when accessing shared data via Open Data Sharing.
Syntax¶
Required parameters¶
nameSpecifies the identifier for the external consumer to add the token to.
ADD { PROGRAMMATIC ACCESS TOKEN | PAT } token_nameCreates a programmatic access token with the specified name.
PATis an alias forPROGRAMMATIC ACCESS TOKEN.
Optional parameters¶
IF NOT EXISTSCreates the token only if a token with the specified name does not already exist for the external consumer. If a token with the same name already exists, the command does nothing and completes successfully without creating a new token or returning a token secret.
DAYS_TO_EXPIRY = integerThe number of days that the token can be used for authentication.
Default:
15COMMENT = 'string_literal'Specifies a comment for the token.
Access control requirements¶
A role used to execute this operation must have the following privileges at a minimum:
| Privilege | Object | Notes |
|---|---|---|
| OWNERSHIP | External Consumer | Required to add a PAT to the external consumer. |
For instructions on creating a custom role with a specified set of privileges, see Creating custom roles.
For general information about roles and privilege grants for performing SQL actions on securable objects, see Overview of Access Control.
Usage notes¶
- You must save the token secret when Snowflake returns it. You cannot retrieve the secret later.
- Provide the token secret and the catalog URI returned by SYSTEM$GET_LISTING_URL_FOR_EXTERNAL_CONSUMER to the external consumer.
Examples¶
Add a PAT to an external consumer:
Add a PAT that expires after 30 days: