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
[CIS-1185] Token provider #2031
Conversation
This is much needed change! The approach is basically the same I took. Great minds think alike :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change LGTM ✅ I would prefer to deprecate the old API instead of removing it though. Is this possible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I were to be the client, I would not be happy with either the previous nor the proposed approaches. Chances are that I want to configure all the things in an initial point in the execution of the app, and only call connect whenever needed, without the need of knowing more about it.
Is this something we should maybe consider? connect
should know nothing of tokens IMO
@polqf yeah, was also thinking about that. The (userID: UserId, completion: @escaping (Result<Token, Error>) -> Void) -> Void Tho it can be done this way, I see 2 potential issues:
The 2nd is more or less fine and expected but 1st contradicts with API alignment we're aiming for. |
Yeah. I do agree with 1, but tbh I don't thing this should be something we base our decisions off. Otherwise there's always a blocking point towards our ideal "excellence" direction Maybe I am proposing something that it is too big for this PR, but I think it worths a discussion, at least. |
Ah, I've got you now. Yes, initializing and configuring chat-client in different places is a good point 👍 But if we go with
As mentioned, the approach with @polqf WDYT? |
@evsaev yeah, as long as there is a discussion to improve this, I am happy to let this through for now 😄 Having it aligned with other SDKs is always better than having it as we have it now. |
130d538
to
7892fe3
Compare
7892fe3
to
e9e047e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff!
e9e047e
to
76e1a4c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! ✅
deab580
to
e7d5263
Compare
e7d5263
to
704ed3c
Compare
Kudos, SonarCloud Quality Gate passed! |
Hi - If I understand this change correctly, there is now no way for the token provider to differentiate between a token needed for the "initial" connection and one that is needed because the current one expired (a refresh). This distinction is critical for the token provider to determine whether or not a cached token can be attempted or not. Before, you could provide the initial token in the There are some workarounds to the new API here but I'm curious what the stream team recommends for this situation. |
Hi @bradleyrzeller! You are correct. For now, you can do the workarounds, and maybe add a boolean flag to check if the method is the first time being called. Currently, we don't have plans to change this, especially because it is aligned with the rest of the platforms. But we will discuss this internally and will let you know if we have updates on this in the future 👍 Best, |
Ok, thanks for the reply @nuno-vieira. I've been testing my workaround here and I am actually not seeing the token provider be called automatically after the token has expired. I am generating a token using your token generator with 1 minute expiry. The token works initially as expected. I can send messages up until it expires ... and then the client disconnects. However, as I mentioned, the client is not invoking my token provider when it clearly knows that the token has expired (api calls return 401s etc.). Can you provide some additional insight here? Thanks! |
Hi, @bradleyrzeller can you provide a snippet of your workaround? |
It's essentially this:
The token provider is only ever invoked once, upon initial connection. I cannot get it to be invoked again even after my token has expired and the client disconnects. |
@nuno-vieira it seems to be because the
but the ErrorPayload expects a This throws off downstream logic that detects token expiration and triggers a refresh... |
Just filed an issue for visibility. |
🔗 Issue Links
CIS-1185
🎯 Goal
Make it possible to pass a
tokenProvider
when connecting the chat-client.📝 Summary
connect
method that takes a token provider as an argument (the same as on other platforms)connect
method that requires a token but with the note that a token must not expiretokenProvider
exposedtokenProvider
that was removed would be glad to hear that the whole flow is simplified:Before:
After:
🧪 Manual Testing Notes
Sign in to the
DemoApp
as a normal/guest/anon user and make sure the connection flow works as before.☑️ Contributor Checklist
🎁 Meme