Access Manager v3 API for Unity SDK

Access Manager isn't enabled by default
Without it, PubNub resources on this keyset have no access controls and clients can reach channels and metadata without permission checks — including Publish, Subscribe, and all other operations. Enable Access Manager in Admin Portal before deploying to production.

Access Manager allows you to enforce security controls for client access to resources within the PubNub Platform. With Access Manager, your servers can grant their clients tokens with embedded permissions that provide access to individual PubNub resources:

  • For a limited period of time.
  • Through resource lists or patterns (regular expressions).
  • In a single API request, even if permission levels differ (read to channel1 and write to channel2).

You can add the authorizedUuid parameter to the grant request to restrict the token usage to one client with a given userId. Once specified, only this authorizedUuid will be able to use the token to make API requests for the specified resources, according to permissions given in the grant request.

User ID / UUID

User ID is also referred to as UUID/uuid in some APIs and server responses but holds the value of the userId parameter you set during initialization.

Grant token​

Requires Access Manager add-on

This method requires that the Access Manager add-on is enabled for your key in the Admin Portal. See Enable the features your app calls.

Requires Secret Key authentication

Granting permissions to resources should be done by administrators whose SDK instance has been initialized with a Secret Key (available on the Admin Portal on your app's keyset).

The GrantToken() method generates a time-limited authorization token with an embedded access control list. The token defines time to live (TTL), AuthorizedUuid, and a set of permissions giving access to one or more resources:

  • Channels
  • ChannelGroups
  • Uuids (App Context UUID metadata, such as names or avatars)
  • Users (DataSync User objects)
  • DataSync (DataSync entities, relationships, and memberships)
  • Categories (list all channel or UUID metadata on the subscribe key, not one named resource)

Only this AuthorizedUuid will be able to use the token with the defined permissions. The authorized client will send the token to PubNub with each request until the token's TTL expires. Any unauthorized request or a request made with an invalid token will return a 403 with a respective error message.

The grant request allows your server to securely grant clients access to resources on the PubNub platform. Each resource type supports a specific set of operations:

ResourcePermissions
channelsread, write, get, manage, update, join, delete
groupsread, manage
uuidsget, update, delete
userscreate, get, update, delete
dataSync (entities, relationships, memberships)create, get, update, delete
categories (Channels, Uuids)get only

In GrantToken(), Categories sets Channels.Get for channel metadata and Uuids.Get for UUID metadata.

  • A category permission lets a token list all metadata of one resource type on your subscribe key. Valid categories are channels and uuids. The only permission is get (32).
  • A get permission on one named channel or user, or on a pattern, does not grant a category.
  • A token can contain only categories. It needs no resource or pattern.
  • When enumeration enforcement is enabled for a keyset, App Context list requests from a token or auth key without the matching category permission return a 403 error.

Setting Get to false leaves the category out of the token.

For a full mapping of permissions to API operations, refer to Manage Permissions with Access Manager v3.

DataSync user and channel objects are protected through the existing Users and Channels resource types, not through a separate DataSync scope. Uuids grants App Context metadata permissions and does not authorize DataSync user operations. Only DataSync entities, relationships, and memberships use the DataSync scope. Refer to DataSync access control for the full permission and resource-type mapping.

read, write, manage, and join stay messaging concepts and are not interpreted on Uuids, Users, or any DataSync resource.

danger
Don't mix Uuids with Users

Uuids and Users serialize to separate token scopes used by different products. The Unity grant builder nevertheless treats them as mutually exclusive across Resources and Patterns: supplying both can throw an ArgumentException or cause Users entries to be omitted with a warning. Use Uuids for App Context metadata grants and Users for DataSync user grants, in separate grant calls when you need both.

Method(s)​

1pubnub.GrantToken()
2 .TTL(int)
3 .Meta(Dictionary<string, object>)
4 .AuthorizedUuid(string)
5 .Resources(PNTokenResources)
6 .Patterns(PNTokenPatterns)
7 .Categories(PNTokenCategories)
8 .DataSyncProjections(PNDataSyncProjections)
9 .QueryParam(Dictionary<string,object>)
10 .Execute(System.Action<PNAccessManagerTokenResult, PNStatus>)
* required
ParameterDescription
TTL *
Type: int
Default:
n/a
Total number of minutes for which the token is valid.
  • The minimum allowed value is 1.
  • The maximum is 43,200 minutes (30 days).
Meta
Type: Dictionary<string, object>
Default:
n/a
Extra metadata to be published with the request. Values must be scalar only; arrays or objects aren't supported.
AuthorizedUuid
Type: string
Default:
n/a
Single Uuid which is authorized to use the token to make API requests to PubNub.
Resources
Type: PNTokenResources
Default:
n/a
Object containing channel, channel group, UUID metadata, and DataSync permissions.
Patterns
Type: PNTokenPatterns
Default:
n/a
Object containing permissions to apply to all channel, channel group, UUID metadata, and DataSync resources matching the RegEx pattern.
Categories
Type: PNTokenCategories
Default:
n/a
Category grants that let the token list all metadata of a type on the subscribe key. Set Channels.Get to list all channel metadata and Uuids.Get to list all UUID metadata. Categories with Get set to false are omitted from the token.
DataSyncProjections
Type: PNDataSyncProjections
Default:
n/a
Object assigning field-level projections to DataSync resources.
QueryParam
Type: Dictionary<string, object>
Default:
n/a
Dictionary object to pass name/value pairs as query string params with PubNub URL request for debug purposes.
Execute
Type: System.Action
Default:
n/a
System.Action of type PNAccessManagerTokenResult.
ExecuteAsync
Type: None
Default:
n/a
Returns Task<PNResult<PNAccessManagerTokenResult>>.

PNTokenResources contains the following properties:

* required
ParameterDescription
Channels
Type: Dictionary<string, PNTokenAuthValues>
Default:
n/a
Dictionary object containing channel permissions.
ChannelGroups
Type: Dictionary<string, PNTokenAuthValues>
Default:
n/a
Dictionary object containing channel group permissions.
Uuids
Type: Dictionary<string, PNTokenAuthValues>
Default:
n/a
Dictionary object containing App Context UUID metadata permissions. Does not authorize DataSync users and cannot be combined with Users in one grant.
Users
Type: Dictionary<string, PNTokenAuthValues>
Default:
n/a
Dictionary object containing DataSync user permissions. Cannot be combined with Uuids in one grant.
DataSync
Type: PNDataSyncTokenScopes
Default:
n/a
Object containing DataSync resource permissions keyed by exact entity, relationship, or membership id.

PNTokenPatterns contains the following properties:

* required
ParameterDescription
Channels
Type: Dictionary<string, PNTokenAuthValues>
Default:
n/a
Dictionary object containing permissions to apply to all channels matching the RegEx pattern.
ChannelGroups
Type: Dictionary<string, PNTokenAuthValues>
Default:
n/a
Dictionary object containing permissions to apply to all channel groups matching the RegEx pattern.
Uuids
Type: Dictionary<string, PNTokenAuthValues>
Default:
n/a
Dictionary object containing App Context UUID metadata permissions for matching IDs. Does not authorize DataSync users and cannot be combined with Users in one grant.
Users
Type: Dictionary<string, PNTokenAuthValues>
Default:
n/a
Dictionary object containing DataSync user permissions for matching IDs. Cannot be combined with Uuids in one grant.
DataSync
Type: PNDataSyncTokenScopes
Default:
n/a
Object containing DataSync resource permissions to apply to all entities, relationships, or memberships matching the RegEx pattern.

PNDataSyncTokenScopes contains the following properties:

* required
ParameterDescription
Entities
Type: Dictionary<string, PNTokenAuthValues>
Default:
n/a
Dictionary object containing entity permissions keyed by exact id (Resources) or RegEx pattern (Patterns).
Relationships
Type: Dictionary<string, PNTokenAuthValues>
Default:
n/a
Dictionary object containing relationship permissions keyed by exact id (Resources) or RegEx pattern (Patterns).
Memberships
Type: Dictionary<string, PNTokenAuthValues>
Default:
n/a
Dictionary object containing membership permissions keyed by exact id (Resources) or RegEx pattern (Patterns).

PNTokenCategories contains the following properties:

* required
ParameterDescription
Channels
Type: PNTokenCategoryPermissions
Default:
Get is false
Permission to list all channel metadata.
Uuids
Type: PNTokenCategoryPermissions
Default:
Get is false
Permission to list all UUID metadata.

PNTokenCategoryPermissions has one bool property, Get. It is the only permission a category accepts. The SDK sends the get permission (32) for each category with Get set to true.

PNTokenAuthValues contains the following properties:

Property NameTypeDescription
ReadboolRead permission. Applies to Subscribe, History, and Presence.
WriteboolWrite permission. Applies to Publish.
ManageboolManage permission. Applies to Channel Groups and App Context.
CreateboolCreate permission. Applies to DataSync.
DeleteboolDelete permission. Applies to History, App Context, and DataSync.
GetboolGet permission. Applies to App Context and DataSync.
UpdateboolUpdate permission. Applies to App Context and DataSync.
JoinboolJoin permission. Applies to App Context.

For DataSync resources, only Create, Get, Update, and Delete are meaningful. Set only those four properties and leave Read, Write, Manage, and Join false (the default), the backend doesn't interpret them for DataSync resources.

PNDataSyncProjections contains the following properties:

* required
ParameterDescription
Resources
Type: PNDataSyncProjectionScope
Default:
n/a
Projection assignments for exact resource ids.
Patterns
Type: PNDataSyncProjectionScope
Default:
n/a
Projection assignments keyed by RegEx pattern.

PNDataSyncProjectionScope contains the following properties:

* required
ParameterDescription
Entities
Type: Dictionary<string, string>
Default:
n/a
id (or RegEx pattern) to projection name.
Users
Type: Dictionary<string, string>
Default:
n/a
id (or RegEx pattern) to projection name.
Channels
Type: Dictionary<string, string>
Default:
n/a
id (or RegEx pattern) to projection name.
Relationships
Type: Dictionary<string, string>
Default:
n/a
id (or RegEx pattern) to projection name.
Memberships
Type: Dictionary<string, string>
Default:
n/a
id (or RegEx pattern) to projection name.

Projections control which payload fields a token can read and write on a DataSync resource. Each id (or pattern) maps to one projection name, __default__ is the platform's built-in base projection, and exact id assignments (Resources) take priority over pattern matches (Patterns). A resource that matches neither falls back to __default__. The SDK passes any projection name through as an opaque string, __default__ isn't validated or defaulted client-side, it's a platform convention rather than an SDK-enforced value. A grant request that sets only DataSyncProjections, without any Resources or Patterns permissions, is still valid. Refer to the DataSync projections guide for how a token selects a projection.

A projection is declared per property on the class definition, so the names you can assign here are the ones the entity class or relationship class declares. A class allows at most 3 distinct projection names in total, and __default__ counts toward that 3 as soon as any property uses it, which leaves 2 custom names in practice.

note
PNDataSyncProjectionScope covers all five resource kinds

The platform accepts projection assignments for five DataSync resource kinds: entities, users, channels, relationships, and memberships. PNDataSyncProjectionScope exposes Entities, Users, Channels, Relationships, and Memberships, so you can assign a projection to a DataSync user or channel object the same way you would to an entity. Permission (not projection) for those same user and channel objects still comes from the top-level Users and Channels scopes. Uuids applies only to App Context metadata. DataSyncProjections only decides which fields of the object a token can read and write.

Projections also scope real-time event payloads, and each named projection publishes its view to a separate __<projection>__<id> channel. A token's projection assignment does not automatically select or authorize that event channel, so control who receives restricted fields with Channels grants on the projection channels. Refer to Projection channels.

Required key/value mappings

For a successful grant request, you must specify permissions for at least one UUID, channel, group, or DataSync resource, or a DataSyncProjections assignment, either as a resource list (Resources) or as a pattern (RegEx, Patterns). A Categories grant alone also satisfies this requirement.

Sample code​

Reference code
This example is a self-contained code snippet ready to be run. It includes necessary imports and executes methods with console logging. Use it as a reference when working with other examples in this document.
1

Returns​

The GrantToken() operation returns PNResult<PNAccessManagerTokenResult> which contains the following properties:

PropertyDescription
Result
Type: PNAccessManagerTokenResult
Returns a PNAccessManagerTokenResult object.
Status
Type: PNStatus
Returns a PNStatus object.

PNAccessManagerTokenResult contains the following properties:

* required
ParameterDescription
Token *
Type: String
Current token with embedded permissions.
1{ "Token":"p0thisAkFl043rhDdHRsCkNyZXisRGNoYW6hanNlY3JldAFDZ3Jwsample3KgQ3NwY6BDcGF0pERjaGFuoENnctokenVzcqBDc3BjoERtZXRhoENzaWdYIGOAeTyWGJI"}

Other examples​

Grant an authorized client different levels of access to various resources in a single call​

The code below grants my-authorized-uuid:

  • Read access to channel-a, channel-group-b, and get to uuid-c.
  • Read/write access to channel-b, channel-c, channel-d, and get/update to uuid-d.
1

Grant an authorized client read access to multiple channels using RegEx​

The code below grants my-authorized-uuid read access to all channels that match the channel-[A-Za-z0-9] RegEx pattern.

1

Grant an authorized client different levels of access to various resources and read access to channels using RegEx in a single call​

The code below grants the my-authorized-uuid:

  • Read access to channel-a, channel-group-b, and get to uuid-c.
  • Read/write access to channel-b, channel-c, channel-d, and get/update to uuid-d.
  • Read access to all channels that match the channel-[A-Za-z0-9] RegEx pattern.
1

Grant an authorized client access to list all channel and uuid metadata​

The code below grants my-authorized-uuid the get category permission for both channels and uuids, so the client can list all channel and uuid metadata on the subscribe key.

1

Grant an authorized client access to DataSync resources​

The code below grants user-alice get access to the entity product-sneaker-42 and get access to all entities that match the product-.* RegEx pattern. DataSync users such as user-bob are not permissioned under DataSync, grant them through the top-level Users scope instead.

1

Grant a token with a field-level projection​

The code below grants user-alice the same access as above and assigns the public projection to the entity product-sneaker-42. With this projection, Alice reads and writes only the fields that the public projection exposes on that entity.

1

Error responses​

If you submit an invalid request, the server returns HTTP 400 with a message that identifies the missing or incorrect argument. Causes can include a RegEx issue, an invalid timestamp, or incorrect permissions.

Revoke token​

Requires Access Manager add-on

This method requires that the Access Manager add-on is enabled for your key in the Admin Portal. See Enable the features your app calls.

Enable token revoke

To revoke tokens, you must first enable this feature on the Admin Portal. To do that, navigate to your app's keyset and mark the Revoke v3 Token checkbox in the ACCESS MANAGER section.

The RevokeToken() method allows you to disable an existing token and revoke all permissions embedded within. You can only revoke a valid token previously obtained using the GrantToken() method.

Use this method for tokens with TTL less than or equal to 30 days. If you need to revoke a token with a longer TTL, contact support.

For more information, refer to Revoke permissions.

Method(s)​

1pubnub.RevokeToken()
2 .Token(string)
3 .QueryParam(Dictionary<string, object>)
4 .Execute(System.Action<PNAccessManagerRevokeTokenResult, PNStatus>)
* required
ParameterDescription
Token *
Type: string
Default:
n/a
Existing token with embedded permissions.
QueryParam
Type: Dictionary<string, object>
Default:
n/a
Dictionary object to pass name/value pairs as query string params with PubNub URL request for debug purposes.
Execute
Type: System.Action
Default:
n/a
System.Action of type PNAccessManagerRevokeTokenResult.
ExecuteAsync
Type: None
Default:
n/a
Returns Task<PNResult<PNAccessManagerRevokeTokenResult>>.

Sample code​

1

Returns​

The RevokeToken() operation returns PNResult<PNAccessManagerRevokeTokenResult> which contains the following properties:

PropertyDescription
Result
Type: PNAccessManagerRevokeTokenResult
Returns an empty PNAccessManagerRevokeTokenResult object when the token revocation request is successful.
Status
Type: PNStatus
Returns a PNStatus object for operations ending in success or failure.

Error Responses​

If you submit an invalid request, the server returns an error status code with a descriptive message informing which of the provided arguments is missing or incorrect. Depending on the root cause, this operation may return the following errors:

  • 400 Bad Request
  • 403 Forbidden
  • 503 Service Unavailable

Parse token​

The ParseToken() method decodes an existing token and returns the object containing permissions embedded in that token. The client can use this method for debugging to check the permissions to the resources or find out the token's TTL details. The returned PNTokenContent also reports whether the token allows listing all channel or UUID metadata, through its Categories property.

If the token was granted with DataSync resource permissions, DataSync projections, or both, ParseToken() also decodes those into the returned object. Resources.DataSync and Patterns.DataSync (both of type PNDataSyncTokenScopes) expose the decoded entity, relationship, and membership permissions, and a Projections property (type PNDataSyncProjections) exposes the decoded projection assignments. The DataSync, Users, and Meta keys appear only when the token actually granted them, so guard the access when you read one.

Method(s)​

1ParseToken(String token)
* required
ParameterDescription
token *
Type: String
Current token with embedded permissions.

Sample code​

1

Returns​

1

When the parsed token carries DataSync permissions or projections, the returned PNTokenContent also includes them. Resources.DataSync and Patterns.DataSync hold the same Entities, Relationships, and Memberships dictionaries described under Grant token, and Projections holds the same Resources/Patterns projection scopes accepted by .DataSyncProjections(). For example, a token granted with the product-sneaker-42 entity permission and the public projection from that entity parses to a Resources.DataSync.Entities entry for product-sneaker-42 and a Projections.Resources.Entities entry mapping product-sneaker-42 to "public".

To better understand the structure of the TokenContents object, see the details of all related custom types:

  • TokenContents
ParameterDescription
Resources
Type: TokenResources
Resource permissions specified in a sequence.
Patterns
Type: TokenPatterns
Resource permissions expressed as RegEx patterns.
Categories
Type: PNTokenCategories
Category-level permissions to list all channel or UUID metadata. Always set.
Meta
Type: Dictionary<string, object>
Extra metadata to be published with the request. Values must be scalar only; arrays or objects aren't supported.
Signature
Type: string
HMAC+SHA256 signed with a PubNub confidential signing key.
Version
Type: int
Version of the token structure.
Timestamp
Type: long
Parameter generated on the server side to record the time when the token was created.
TTL
Type: int
Total number of minutes for which the token is valid.
  • The minimum allowed value is 1.
  • The maximum is 43,200 minutes (30 days).
AuthorizedUUID
Type: string
Single UUID which is solely authorized to use the token to make API requests to PubNub.
  • TokenResources
ParameterDescription
Channels
Type: Dictionary<string, TokenAuthValues>
Individual or sequential channel permissions.
Groups
Type: Dictionary<string, TokenAuthValues>
Individual or sequential group permissions.
UUIDs
Type: Dictionary<string, TokenAuthValues>
Individual or sequential UUID permissions. This resource is only used in Objects v2 operations.
  • TokenPatterns
ParameterDescription
Channels
Type: Dictionary<string, TokenAuthValues>
Channel permissions expressed as RegEx patterns.
Groups
Type: Dictionary<string, TokenAuthValues>
Group permissions expressed as RegEx patterns.
UUIDs
Type: Dictionary<string, TokenAuthValues>
UUID permissions expressed as RegEx patterns. This resource is only used in Objects v2 operations.
  • TokenAuthValues

    • Read (bool)
    • Write (bool)
    • Manage (bool)
    • Delete (bool)
    • Get (bool)
    • Update (bool)
    • Join (bool)

Category permissions​

Categories on the returned PNTokenContent is always set. Categories.Channels.Get is true only when the token can list all channel metadata, and Categories.Uuids.Get is true only when it can list all UUID metadata. A category the token doesn't carry is false, not null. Named resource permissions in Resources and Patterns don't change these values.

The code below parses a token and reads its category permissions.

1

Error Responses​

If you receive an error while parsing the token, it may suggest that the token is damaged. In that case, request the server to issue a new one.

Set token​

The SetAuthToken() method is used by the client devices to update the authentication token granted by the server.

Method(s)​

1SetAuthToken(String token)
* required
ParameterDescription
token *
Type: String
Current token with embedded permissions.

Sample code​

1

Returns​

This method doesn't return any response value.

Grant token - spaces & users (deprecated)​

Requires Access Manager add-on

This method requires that the Access Manager add-on is enabled for your key in the Admin Portal. See Enable the features your app calls.

The GrantToken() method generates a time-limited authorization token with an embedded access control list. The token defines time to live (TTL), AuthorizedUserId, and a set of permissions giving access to one or more resources:

  • Spaces
  • Users (other users' metadata, such as their names or avatars)

Only this AuthorizedUserId will be able to use the token with the defined permissions. The authorized client will send the token to PubNub with each request until the token's TTL expires. Any unauthorized request or a request made with an invalid token will return a 403 with a respective error message.

Permissions - spaces & users (deprecated)​

The grant request allows your server to securely grant your clients access to the resources within the PubNub Platform. There is a limited set of operations the clients can perform on every resource:

ResourcePermissions
Spacesread, write, get, manage, update, join, delete
Usersget, update, delete

For permissions and API operations mapping, refer to Manage Permissions with Access Manager v3.

TTL - spaces & users (deprecated)​

The TTL (time to live) parameter is the number of minutes before the granted permissions expire. The client will require a new token to be granted before expiration to ensure continued access. ttl is a required parameter for every grant call and there is no default value set for it. The max value for ttl is 43,200 (30 days).

For more details, see TTL in Access Manager v3.

RegEx - spaces & users (deprecated)​

If you prefer to specify permissions by setting patterns, rather than listing all resources one by one, you can use regular expressions. To do this, set RegEx permissions as Patterns before making a grant request.

For more details, see RegEx in Access Manager v3.

Authorized user ID - spaces & users (deprecated)​

Setting an AuthorizedUserId in the token helps you specify which client device should use this token in every request to PubNub. This will ensure that all requests to PubNub are authorized before PubNub processes them. If AuthorizedUserId isn't specified during the grant request, the token can be used by any client with any UserId. It's recommended to restrict tokens to a single AuthorizedUserId to prevent impersonation.

For more details, see Authorized UUID in Access Manager v3.

Method(s) - spaces & users (deprecated)​

1pubnub.GrantToken()
2 .TTL(int)
3 .Meta(Dictionary<string, object>)
4 .AuthorizedUserId(string)
5 .Resources(PNTokenResources)
6 .Patterns(PNTokenPatterns)
7 .QueryParam(Dictionary<string,object>)
8 .Execute(System.Action<PNAccessManagerTokenResult, PNStatus>)
* required
ParameterDescription
TTL *
Type: int
Default:
n/a
Total number of minutes for which the token is valid.
  • The minimum allowed value is 1.
  • The maximum is 43,200 minutes (30 days).
Meta
Type: Dictionary<string, object>
Default:
n/a
Extra metadata to be published with the request. Values must be scalar only; arrays or objects aren't supported.
AuthorizedUserId
Type: string
Default:
n/a
Single Uuid which is authorized to use the token to make API requests to PubNub.
Resources
Type: PNTokenResources
Default:
n/a
Object containing channel, channel group, and UUID metadata permissions.
Patterns
Type: PNTokenPatterns
Default:
n/a
Object containing permissions to apply to all channel, channel group, and UUID metadata matching the RegEx pattern.
QueryParam
Type: Dictionary<string, object>
Default:
n/a
Dictionary object to pass name/value pairs as query string params with PubNub URL request for debug purposes.
Execute
Type: PNCallback
Default:
n/a
System.Action of type PNAccessManagerTokenResult.
ExecuteAsync
Type: None
Default:
n/a
Returns Task<PNResult<PNAccessManagerTokenResult>>.

PNTokenResources contains the following properties:

* required
ParameterDescription
Spaces
Type: Dictionary<string, PNTokenAuthValues>
Default:
n/a
Dictionary object containing Space permissions.
Users
Type: Dictionary<string, PNTokenAuthValues>
Default:
n/a
Dictionary object containing User metadata permissions.

PNTokenPatterns contains the following properties:

* required
ParameterDescription
Spaces
Type: Dictionary<string, PNTokenAuthValues>
Default:
n/a
Dictionary object containing permissions to apply to all Spaces matching the RegEx pattern.
Users
Type: Dictionary<string, PNTokenAuthValues>
Default:
n/a
Dictionary object containing permissions to apply to all User metadata matching the RegEx pattern.

PNTokenAuthValues contains the following properties:

Property NameTypeDescription
ReadboolRead permission.
WriteboolWrite permission.
ManageboolManage permission.
DeleteboolDelete permission.
GetboolGet permission.
UpdateboolUpdate permission.
JoinboolJoin permission.
Required key/value mappings

For a successful grant request, you must specify permissions for at least one User or Space either as a resource list or as a pattern (RegEx).

Sample code - spaces & users (deprecated)​

1

Returns - spaces & users (deprecated)​

The GrantToken() operation returns PNResult<PNAccessManagerTokenResult> which contains the following properties:

PropertyDescription
Result
Type: PNAccessManagerTokenResult
Returns a PNAccessManagerTokenResult object.
Status
Type: PNStatus
Returns a PNStatus object.

PNAccessManagerTokenResult contains the following properties:

* required
ParameterDescription
Token *
Type: String
Current token with embedded permissions.
1{ "Token":"p0thisAkFl043rhDdHRsCkNyZXisRGNoYW6hanNlY3JldAFDZ3Jwsample3KgQ3NwY6BDcGF0pERjaGFuoENnctokenVzcqBDc3BjoERtZXRhoENzaWdYIGOAeTyWGJI"}

Other examples - spaces & users (deprecated)​

Grant an authorized client different levels of access to various resources in a single call - spaces & users (deprecated)​

The code below grants my-authorized-userId:

  • Read access to space-a, and get to userId-c.
  • Read/write access to space-b, space-c, space-d, and get/update to userId-d.
1

Grant an authorized client read access to multiple spaces using RegEx - spaces & users (deprecated)​

The code below grants my-authorized-userId read access to all channels that match the space-[A-Za-z0-9] RegEx pattern.

1

Grant an authorized client different levels of access to various resources and read access to spaces using RegEx in a single call - spaces & users (deprecated)​

The code below grants the my-authorized-userId:

  • Read access to space-a and userId-c.
  • Read/write access to space-b, space-c, space-d, and get/update to userId-d.
  • Read access to all channels that match the space-[A-Za-z0-9] RegEx pattern.
1

Error Responses - spaces & users (deprecated)​

If you submit an invalid request, the server returns the 400 error status code with a descriptive message informing which of the provided arguments is missing or incorrect. These can include, for example, issues with a RegEx, a timestamp, or permissions.

Was this page useful?

Last updated on