-
Notifications
You must be signed in to change notification settings - Fork 56
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
sdk.ensureLoggedIn returns prior user's login status #214
Comments
After reading the code carefully, it seems be a JS programming issue. You are printing In JS, primitive data types such as string are passed by value. So even the SDK changes the value of the I am trying to reproduce it. |
Hi @tylerlong, Thanks for looking into this and trying to reproduce this issue on your end. The point of logging the username was to illustrate the point that even though we are creating a new instance of the sdk like so: const sdk = new SDK({
server,
clientId,
clientSecret,
}) and then calling |
It is by design (not designed by me though). ringcentral-js/sdk/src/platform/Auth.ts Lines 14 to 40 in dcb63a6
By default it will read the cache in local storage: ringcentral-js/sdk/src/core/Cache.ts Line 39 in dcb63a6
|
To workaround it, for different SDK instances, specify different Line 61 in dcb63a6
|
@tylerlong great, thanks will do that! |
based on findings in this issue: ringcentral#214
based on findings in this issue: ringcentral#214
based on findings in this issue: ringcentral#214
* misc: add password grant deprecated warning * feat: expose userAgent * Add docs on use of cachePrefix based on findings in this issue: #214 --------- Co-authored-by: Elridge D'Mello <[email protected]>
It's causing more trouble to developers:
Let's find a way to fix it. |
Umm... If they are developing something that has multiple client-ids, using those client-ids should be fairly explicit? Can't they just have a cachePrefix set for each client-ids used? I thought cachePrefix is implemented exactly to solve this problem? Honestly, I don't think the cachePrefix design here is exactly great. But implicitly partition the cache based on client-id can be problematic as well. I'd rather have something like const cache = new Cache('myNameSpace');
const sdk = new SDK({ ..., cache }); and just let developers manage their own caching space explicitly. @embbnux Dunno, I think I'd be very supportive of a breaking change for this for a major release. |
Most developers don't know that the SDK caches tokens. It will surprise them that two SDK instances magically share the same token. And sometimes it will cause security issues because the SDK instance may perform actions on behalf of a wrong user. For next major release. We could make it explicit: developers need to explicitly specify cache settings. Even they don't need cache at all, they need to explicitly specify something like "cache=false". It will be a breaking change anyway. Break it at development time so that it won't affect production. |
Hello,
We have a use case where we need to have two users log into the RC SDK and use the two instances for different purposes (SMS sending vs non-SMS API requests).
What we found is that when we create
new
SDK instances and then check the login status, the second instance will reflect the login status of the first. We are using "@ringcentral/sdk": "4.7.4"Code below to demonstrate the issue:
Code to test the above module/demonstrate the issue:
Output of running the code with valid credentials (notice that the
logging in 1aaabbbb1966
output is missing!):What we would expect (since we're creating a
new
sdk instance):The text was updated successfully, but these errors were encountered: