manager = pam.access(
pubkey="pam",
subkey="pam",
seckey="pam"
)Grant access to user with authkey of gZW5jb2RlZCBmaWx with read and write access for 5 minute ttl.
print manager.grant(
channel="my_channel",
authkey="gZW5jb2RlZCBmaWx",
read=True,
write=True,
ttl=5 ## Minutes
)Also grant access to the presence channel (required for PubNub Dev Console).
print manager.grant(
channel=[ "my_channel", "my_channel-pnpres" ],
authkey="gZW5jb2RlZCBmaWx",
read=True,
write=True,
ttl=5 ## Minutes
)Exclude the authkey and you can global grant access to all.
print manager.grant(
channel="my_channel_all",
read=True,
write=True,
ttl=5 ## Minutes
)You can grant access forever by setting the ttl param to 0.
print manager.grant(
channel="my_channel-pnpres",
authkey="gZW5jb2RlZCBmaWx",
read=True,
write=True,
ttl=0 ## FOREVER
)Instantly revoke access to a user.
print manager.revoke(
channel="some-other-channel",
authkey="gZW5jb2RlZCBmaWx"
)You can also revoke Global Access by excluding the authkey param.
print manager.revoke(
channel="some-other-channel"
)You can also Audit Access by running audit().
print manager.audit(
channel="some-other-channel",
authkey="gZW5jb2RlZCBmaWx" ## Optional Auth Key
)Or Audit Access for all users on a channel (exclude the authkey param).
print manager.audit(
channel="some-other-channel"
)Or Audit Access for all channels (exclude the authkey and channel params).
print manager.audit()WARNING: PubNub Dev Console Requires Grant on Presence Channel too! You can set the presence access by granting on the suffix of -pnpres channel name.
http://www.pubnub.com/console/?channel=my_channel&sub=pam&pub=pam&sec=pam
See: https://gist.github.com/stephenlb/8164176#file-pam-md