-
Notifications
You must be signed in to change notification settings - Fork 52
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
Can't authenticate request #16
Comments
What makes you think that it's not supported? Though I'm not sure how well / if it works on the Web. |
Oh.. It has passed a bit of time, i don t really Remember what the point
was. I m developing an app for both mobile and web. I ended up using Dio
for mobile and wrote a js wrapper around polyfill to solve It. But it would
be nice to use only 1 external library like eventsource. As i ll have some
free time in november i ll test again eventsource package to see what was
the situation with the features.
(As i Remember It didn t work on web)
Il ven 9 ott 2020, 13:36 jonasbark <[email protected]> ha scritto:
… What makes you think that it's not supported?
The connect method accepts a header argument:
https://github.com/stevenroose/dart-eventsource/blob/master/lib/eventsource.dart#L61
Though I'm not sure how well / if it works on the Web.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#16 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AN3UJSDIVGIWU4TXY5WGWDLSJ3YSZANCNFSM4QKWDENA>
.
--
------------------------
Indirizzo istituzionale di posta elettronica
degli studenti e dei laureati dell'Università degli Studi di TorinoOfficial
University of Turin email address for students and graduates
|
@VittorioParagallo Could you share your solution for Web? Having the same issue with Web implementation |
@VittorioParagallo can you please share how you managed to use Dio for SSE with authorization headers? - I am trying the same and it connects but doesn't stream the data |
I uploaded the code in my repo. I guess that taking my code and following these steps can you easily to the solution. (my repo is a fully working app) At first add this js file to the web folder of your flutter project(it's the polyfill): Then we need to call that javascript object from dart. You can download the whole folder, it contains 5 files:
Now that everything is set, is possible to develop the api, the one i did is rest_api_service.dart.
So the import dinamically loads the right file wether is a web app or not. That's why a stub with all unimplemented closures was needed. In the same file you can see the normal get (baseUrl is the webserver and url is the right part endpoint): `
` (_returnResponse check if it has data or error status, check at the end of the file). This uses the conventional 'package:http/http.dart' and returns just one result.
Works the same way, but returns the EventSource object which is a stream, and continues to stream data till it's closed.
It just prepares the header with the bearer token. I hope it helps. I just tested again the code and it works great! |
Is it possible to add the possibility to add authorization header?
without it becomes useless in a secured environment :(
i've been looking all around last two days and it looks like this feature is missing in the original eventsource api, but there are some implementations with polyfill
The text was updated successfully, but these errors were encountered: