pubnub / dart

PubNub Dart SDK
Other
28 stars 15 forks source link

`getFilesUrl` is missing `auth` when using Access Manager v3 #103

Open vsomayaji opened 2 years ago

vsomayaji commented 2 years ago

The first step in migrating from Access Manager v2 to v3 is to remove the authKey from the client-side configuration. When you do that, URLs returned by getFilesUrl start failing with an HTTP 403 error.

It looks like the issue lies here:

https://github.com/pubnub/dart/blob/ed0727428737d5b8b3477ab6871666a2d629e1c3/pubnub/lib/src/dx/files/files.dart#L259

With the PamKeysetExtension, should that be something like this instead:

if (keyset.hasAuth()) 'auth': keyset.getAuth(),

For now, we're working around this by setting the authKey to the token:

    _pubnub = pn.PubNub(
      defaultKeyset: pn.Keyset(
        // TODO: Setting the `authKey` shouldn't be necessary, but there is a bug in the PubNub SDK where
        // [PubNub.files.getFileUrl] does not use the value configured with [PubNub.setToken].
        authKey: token,
        publishKey: publishKey,
        subscribeKey: subscribeKey,
        userId: pn.UserId(userId),
      ),
    );
    _pubnub.setToken(token);