Area: API
Sub-Area: Authentication & Authorization
Applies to: OSS + Cloud
Issue
You try to create a personal access token and get this error:
Unauthorized to perform this action. Please contact your DataHub administrator.
This can happen even when your existing token works for other operations. In the UI, the "Generate new token" button is disabled, or the Access Tokens page shows a lock icon instead of the token list.
You Might Be Asking
- Why does my token work for some operations but not for creating new tokens?
- Can Readers and Editors create personal access tokens?
- What is the difference between creating a token for myself and for another user?
- Why does
NO_EXPIRYfail when I create a token?
Cause
DataHub checks privileges when you create a token. The check depends on the token type:
-
Personal token for yourself: you need the "Generate Personal Access Tokens" platform privilege (
generatePersonalAccessTokens), andactorUrnmust be your own user URN. -
Personal token for another user: you need the "Manage All Access Tokens" platform privilege (
manageTokens). -
Service account token (
type: SERVICE_ACCOUNT): you need the "Manage Service Accounts" privilege (manageServiceAccounts), andactorUrnmust be a service account. Otherwise the call fails withThe specified URN is not a service account: <urn>.
By default, the built-in policy "All Users - Base Platform Privileges" grants Generate Personal Access Tokens to all users, including Readers and Editors. So a 403 usually means one of these:
- An admin edited or deactivated that policy.
- You passed an
actorUrnthat is not your own, and you don't have Manage All Access Tokens.
The UI button is stricter than the API. It is enabled only when token authentication is on and you have Generate Personal Access Tokens. Manage All Access Tokens alone does not enable it. To create a token for another user, use the GraphQL API.
If the Access Tokens page shows "Token based authentication is currently disabled. Contact your DataHub administrator to enable this feature.", token authentication is turned off. That is a different problem from missing privileges.
Solution
- Check your privileges:
{
me {
platformPrivileges {
generatePersonalAccessTokens
manageTokens
manageServiceAccounts
}
}
}
-
If
generatePersonalAccessTokensisfalse, ask an admin to check the policy in Settings > Permissions > Policies. The "All Users - Base Platform Privileges" policy must be active and include Generate Personal Access Tokens, or another active policy must grant it to you. -
Create the token with your own URN and a finite duration:
mutation {
createAccessToken(input: {
type: PERSONAL,
actorUrn: "<your user URN>",
duration: ONE_MONTH,
name: "My Token Name",
description: "Token description"
}) {
accessToken
metadata {
urn
}
}
}
Give exactly one of duration or durationIso (for example P30D). actorUrn and name are required. Valid duration values are ONE_HOUR, ONE_DAY, ONE_WEEK, ONE_MONTH, THREE_MONTHS, SIX_MONTHS, ONE_YEAR and NO_EXPIRY. On create, metadata returns only urn and type.
-
Don't use
NO_EXPIRY. Never-expiring tokens are disabled by default. The request fails withNever-expiring access tokens (NO_EXPIRY) cannot be created because ACCESS_TOKEN_ALLOW_NO_EXPIRY is false.Use a finite duration. AdurationIsooutside the allowed list fails withAccess token duration '<iso>' is not allowed.The default allowed list is PT1H, P1D, P7D, P30D, P90D, P180D and P365D.- Cloud: you can't change this server setting. Contact DataHub Support if you need a different duration policy.
-
Self-hosted: an operator can set
ACCESS_TOKEN_ALLOW_NO_EXPIRYandACCESS_TOKEN_ALLOWED_DURATIONSon GMS.
-
For a service account token, use
type: SERVICE_ACCOUNTwith the service account's URN. You need Manage Service Accounts. See the service accounts guide.
If you can't get the privilege yourself, ask your DataHub administrator to grant it.