Area: API
Sub-Area: Authentication
Applies to: OSS + Cloud
Issue
You create a personal access token with duration: ONE_WEEK and the request fails. Other durations such as ONE_HOUR, ONE_DAY and ONE_MONTH work.
The server error is:
Unrecognized access token duration ONE_WEEK provided
You Might Be Asking
- Is ONE_WEEK a valid duration? Yes. ONE_WEEK is a valid
AccessTokenDurationvalue and equals 7 days. - Which duration values exist? ONE_HOUR, ONE_DAY, ONE_WEEK, ONE_MONTH, THREE_MONTHS, SIX_MONTHS, ONE_YEAR and NO_EXPIRY. Values such as TWO_MONTHS, 1_MONTH or 3_MONTHS do not exist and fail GraphQL validation.
- Can I create a token that never expires? Not by default. See the NO_EXPIRY note below.
Cause
The server maps each duration value to a length of time. If a duration has no mapping, the server throws Unrecognized access token duration <duration> provided. This error appears when your server runs an old release whose duration mapping lacks ONE_WEEK.
Solution
Upgrade to the latest release of DataHub. Current DataHub Cloud (v2.4.4) maps ONE_WEEK to 7 days. DataHub Cloud customers who see this error can contact DataHub Support.
After you upgrade, create the token with GraphQL. Select accessToken and metadata { urn }. expiresAt is not a field of AccessToken.
mutation createAccessToken {
createAccessToken(
input: {
type: PERSONAL,
actorUrn: "urn:li:corpuser:username",
duration: ONE_WEEK,
name: "My Weekly Token"
}
) {
accessToken
metadata {
urn
}
}
}
actorUrn and name are required. Give exactly one of duration or durationIso. If you use durationIso, the value must be in the server's allowed list. The default list is PT1H, P1D, P7D, P30D, P90D, P180D and P365D. Otherwise the server returns Access token duration '<iso>' is not allowed. Choose a value from ACCESS_TOKEN_ALLOWED_DURATIONS (currently: ...).
NO_EXPIRY: Never-expiring tokens are disabled by default in DataHub Cloud v2.2.0 and later. A NO_EXPIRY request then fails and the error says to use a finite duration or set ACCESS_TOKEN_ALLOW_NO_EXPIRY=true. Existing never-expire tokens keep working. Self-hosted operators can set that variable. Cloud customers can't set it and should contact DataHub Support.