Time Units for Tokens¶
This article describes the valid values that can be used to express time units when creating Tokens.
The default time unit is often expressed as Seconds, but additional time unit helpers are available to create time scoped (TTL value) Tokens with shortcut units.
Solution¶
When creating a Token, the following command is often expressed throughout the documentation:
The above examples creates a Token based on the User rocketskates
roles permissions, set to a Time-to-Live (TTL) value of 24 hours, as
expressed in seconds.
The following additional helpers can be used to create eaiser to use and
more intuitive length TTL values. The format is the time specification,
followed by the unit of measure, with no spaces (eg 1m
for 1 minute).
unit | description | example |
---|---|---|
s |
Seconds | 1s, 10s, 86400s |
m |
Minutes | 10m, 30m |
h |
Hours | 1h, 6h |
d |
Days | 1d, 10d |
w |
Weeks | 1w, 5w |
mo |
Months | 1mo, 2mo, 10mo |
y |
Years | 1y, 3y |
never |
~100 years | never |
Note
1s
is equivalent to just 1
, since the default unit is seconds, no trailing
s
is technically required. It is provided for completeness.
No Combined Units¶
Units can not be combined in to more complex strings.
Failure
1w2d
is NOT valid for 9 days (1 week and 2 days).
Additional Information¶
See Also¶
Versions¶
All versions 4.x and newer.
Keywords¶
ttl, scope, token, length, duration, time units, seconds, minutes, hours, days, weeks, months, years