Access Manager v3 API for PubNub Unity SDK

Access Manager allows you to enforce security controls for client access to resources within the PubNub Platform. With Access Manager v3, 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 only one client with a given UUID. Once specified, only this authorized UUID will be able to use the token to make API requests for the specified resources, according to permissions given in the grant request.

For more information about Access Manager v3, refer to Manage Permissions with Access Manager v3.

Client device support only

The Unity SDK supports only client implementation of Access Manager functionality. This means that you cannot use it to grant permissions, but rather to parse and set tokens received from a server SDK.

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 (time to live) details.

Method(s)

ParseToken(string token)
ParameterTypeRequiredDefaultDescription
tokenStringYesn/aCurrent token with embedded permissions.

Basic Usage

pubnub.ParseToken("p0thisAkFl043rhDdHRsCkNyZXisRGNoYW6hanNlY3JldAFDZ3Jwsample3KgQ3NwY6BDcGF0pERjaGFuoENnctokenVzcqBDc3BjoERtZXRhoENzaWdYIGOAeTyWGJI")

Returns

TokenContents p = pubnub.ParseToken("p0thisAkFl043rhDdHRsCkNyZXisRGNoYW6hanNlY3JldAFDZ3Jwsample3KgQ3NwY6BDcGF0pERjaGFuoENnctokenVzcqBDc3BjoERtZXRhoENzaWdYIGOAeTyWGJI")

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

  • TokenContents

    ParameterTypeDescription
    ResourcesTokenResourcesResource permissions specified in a sequence.
    PatternsTokenPatternsResource permissions expressed as RegEx patterns.
    MetaDictionary<string, object>Extra metadata to be published with the request. Values must be scalar only; arrays or objects aren't supported.
    SignaturestringHMAC+SHA256 signed with a PubNub confidential signing key.
    VersionintVersion of the token structure.
    TimestamplongParameter generated on the server side to record the time when the token was created.
    TTLintTotal number of minutes for which the token is valid.
    • The minimum allowed value is 1.
    • The maximum is 43,200 minutes (30 days).
    AuthorizedUUIDstringSingle UUID which is solely authorized to use the token to make API requests to PubNub.
  • TokenResources

    ParameterTypeDescription
    ChannelsDictionary<string, TokenAuthValues>Individual or sequential channel permissions.
    GroupsDictionary<string, TokenAuthValues>Individual or sequential group permissions.
    UUIDsDictionary<string, TokenAuthValues>Individual or sequential UUID permissions. This resource is only used in Objects v2 operations.
  • TokenPatterns

    ParameterTypeDescription
    ChannelsDictionary<string, TokenAuthValues>Channel permissions expressed as RegEx patterns.
    GroupsDictionary<string, TokenAuthValues>Group permissions expressed as RegEx patterns.
    UUIDsDictionary<string, TokenAuthValues>UUID permissions expressed as RegEx patterns. This resource is only used in Objects v2 operations.
  • TokenAuthValues

    ParameterType
    Readbool
    Writebool
    Managebool
    Deletebool
    Createbool
    Getbool
    Updatebool
    Joinbool

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 SetToken() method is used by the client devices to update the authentication token granted by the server.

Method(s)

SetToken(string token)
ParameterTypeRequiredDefaultDescription
tokenStringYesn/aCurrent token with embedded permissions.

Basic Usage

pubnub.SetToken("p0thisAkFl043rhDdHRsCkNyZXisRGNoYW6hanNlY3JldAFDZ3Jwsample3KgQ3NwY6BDcGF0pERjaGFuoENnctokenVzcqBDc3BjoERtZXRhoENzaWdYIGOAeTyWGJI")

Returns

This method doesn't return any response value.

Last updated on