wallforfry / dart_mercure

Dart library for dunglas/mercure
BSD 2-Clause "Simplified" License
13 stars 4 forks source link

Any documentation or example related jwt subscribe for private update. #6

Closed shubhamdhaboya closed 3 years ago

shubhamdhaboya commented 4 years ago

This might be not an issue but also there is nothing i can find in readme.

Thanks

Nalmac commented 4 years ago

I struggled quite a lot today to subscribe to private channels and I came up with this solution (I'm using this to comunicate with a symfony server api):

I request my server the mercure cookie, which is a HTTP header shaped like this => Set-Cookie: mercureAuthorization=*JWT_token*;path=*mercure_path*

Then, I store JWT_token in a String variable, String tokenForPrivateSub for exemple (using a some split() methods).

Once I'm done with that I pass the token in the constructor of my Mercure class :

Mercure mercure = Mercure(hub_url: hub_url, token: tokenForPrivateSub);