grantToken
Legacy grantToken overload having the uuids bucket (App Context v2 UUID metadata). New code should prefer the flat-list overload taking grants: List<TokenGrant>.
Parameters
Time in minutes for which granted permissions are valid.
Additional metadata.
Single uuid which is authorized to use the token to make API requests to PubNub.
List of all channel grants.
List of all channel group grants.
List of all uuid grants.
Set to true to allow listing all channel metadata on the keyset (getAllChannelMetadata). A get on a named channel or a channel pattern doesn't imply this.
Set to true to allow listing all uuid metadata on the keyset (getAllUUIDMetadata). A get on a named uuid or a uuid pattern doesn't imply this.
The modern grantToken: mint a token from a single flat list of grants. Every grant carries its own resource type (ChannelGrant, ChannelGroupGrant or a DataSyncGrantType from DataSyncGrant), so a pub/sub-only customer, an App Context customer and a DataSync customer all use the same product-neutral method. DataSync realtime subscribe is granted with DataSyncGrant.subscribe / DataSyncGrant.subscribePattern, which return a ChannelGrant on the resolved ref-channel.
pubnub.grantToken(
ttl = 60,
grants = listOf(ChannelGrant.name("chat", read = true, write = true)),
).sync().tokenParameters
Time in minutes for which granted permissions are valid.
Single userId which is authorized to use the token, or null for an unbound token.
Additional metadata. Must be null or a map when any grant carries a projection. Must not contain pn-projections: the SDK builds that key from the grants' projection.
Flat list of grants; each grant's type selects its wire bucket.
This function generates a grant token for PubNub Access Manager (PAM).
Permissions can be applied to any of the three type of resources:
channels
channel groups
uuid - metadata associated with particular UUID
Each type of resource have different set of permissions. To know what's possible for each of them check ChannelGrant, ChannelGroupGrant and UUIDGrant.
Legacy grantToken overload having the uuids bucket (App Context v2 UUID metadata). New code should prefer the flat-list overload taking grants: List<TokenGrant>.
Parameters
Time in minutes for which granted permissions are valid.
Additional metadata. Must not contain pn-projections.
Single uuid which is authorized to use the token to make API requests to PubNub
List of all channel grants
List of all channel group grants
List of all uuid grants
Set to true to allow listing all channel metadata on the keyset (getAllChannelMetadata). A get on a named channel or a channel pattern doesn't imply this.
Set to true to allow listing all uuid metadata on the keyset (getAllUUIDMetadata). A get on a named uuid or a uuid pattern doesn't imply this.
The modern grantToken: mint a token from a single flat list of grants for PubNub Access Manager (PAM).
Every grant carries its own resource type (ChannelGrant, ChannelGroupGrant or a DataSyncGrantType from DataSyncGrant), so a pub/sub-only customer, an App Context customer and a DataSync customer all use the same product-neutral method. Each grant type exposes only the permissions relevant to it. DataSync realtime subscribe is granted with DataSyncGrant.subscribe / DataSyncGrant.subscribePattern, which return a ChannelGrant on the resolved ref-channel.
The legacy uuids bucket is intentionally not reachable here — UUIDGrant does not implement TokenGrant. Use the legacy overload for uuids.
Parameters
Time in minutes for which granted permissions are valid.
Single userId which is authorized to use the token to make API requests to PubNub. Pass null to mint a token not bound to a specific authorized userId.
Additional metadata. Must be null or a map when any grant carries a projection. Must not contain pn-projections: the SDK builds that key from the grants' projection.
Flat list of grants; each grant's type selects its wire bucket.
Legacy grantToken overload having the uuids bucket (App Context v2 UUID metadata). New code should prefer the flat-list overload taking grants: List<TokenGrant>.