Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PubNub Ruby SDK: PAM v3 Token Generation Issue #166

Open
sunnybogawat opened this issue Jan 16, 2025 · 0 comments
Open

PubNub Ruby SDK: PAM v3 Token Generation Issue #166

sunnybogawat opened this issue Jan 16, 2025 · 0 comments

Comments

@sunnybogawat
Copy link

I am migrating from Access Manager (PAM) v2 to PAM v3 using the guide provided by PubNub: PAM v3 Migration Guide. As part of this migration, I updated my Ruby code for token generation. However, I’m encountering a 403 Forbidden error on the frontend when a heartbeat call is initiated using the token generated by this code.

Below is the sample code I’m using for token generation

pubnub = Pubnub.new(
  subscribe_key: Settings.pubnub.subscribe_key,
  publish_key: Settings.pubnub.publish_key,
  secret_key: Settings.pubnub.secret_key,
  user_id: user.id.to_s,
)

token_future = pubnub.grant_token(
  ttl: 15,
  authorized_uuid: user.uuid,
  channels: {
    "#{entity_id}#{PUBNUB_CHANNEL_DELIMETER}#{PUBNUB_WILDCARD}": Pubnub::Permissions.res(
      read: true,
      write: true,
      manage: false
    )
  }
)

token_response = token_future.value
if token_response.is_a?(Pubnub::Envelope) && token_response.status[:code] == 200
  token = token_response.result[:data]["token"]
end
return token

Key Issues:

  • Forbidden Error: The frontend encounters a 403 Forbidden error during heartbeat calls made using the token generated with the above code.

  • Token Validation: How can I validate if the token generated through this code is valid?

  • Documentation and Examples: Is there more specific documentation or a code sample available for generating tokens using the Ruby SDK with PAM v3?

Questions:

  • Is the provided code snippet the correct way to generate a token for PAM v3 using the PubNub Ruby SDK?

  • Are there additional configurations or steps required to ensure the generated token works correctly for heartbeat calls?

  • Are there any available tools or methods to debug or validate the generated token?

Environment Details:

  • PubNub gem version: [5.3.5]

  • Ruby Version: [3.0.7]

  • Rails Version: [6.1]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant