ALTER EXTERNAL CONSUMER … ROTATE PROGRAMMATIC ACCESS TOKEN (PAT)¶
Rotates a Programmatic Access Token (PAT) for an external consumer, generating a new token secret and expiring the existing one.
The new secret uses the same DAYS_TO_EXPIRY value set when the token was first created.
Syntax¶
Required parameters¶
nameSpecifies the identifier for the external consumer.
ROTATE { PROGRAMMATIC ACCESS TOKEN | PAT } token_nameRotates the programmatic access token with the specified name.
PATis an alias forPROGRAMMATIC ACCESS TOKEN.
Optional parameters¶
IF EXISTSRotates the token only if a token with the specified name exists. If no token with that name exists, the command does nothing and completes successfully instead of returning an error.
EXPIRE_ROTATED_TOKEN_AFTER_HOURS = integerSets the number of hours after which the prior token secret expires. Set to
0to expire the prior secret immediately.Default:
24
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 rotate a PAT for 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 new token secret when Snowflake returns it. You cannot retrieve the secret later.
- Provide the new token secret to the external consumer to replace the prior secret before it expires.
Examples¶
Rotate a PAT for an external consumer:
Rotate a PAT and expire the prior secret immediately: