ringcentral/ringcentral-js

Unable to authenticate using an email address as a username

byrnereese opened this issue · 7 comments

I was doing some testing to verify that Glip Pro users can login to the production API. In the process, I found a bug. It is arguable whether the bug is in the platform or the SDK, but I have verified that I can fix this issue by modifying the SDK. The bug is simple.

Glip Pro users login using an email address and a password. No extension is used. However, the Javascript SDK transmits an extension parameter in the call to https://platform.ringcentral.com/restapi/oauth/token:

 grant_type=password&username=byrne.reese%40xyz.com&password=xxxxxxxx&extension=

This causes an "Invalid resource owner credentials error." By modifying the SDK to not transmit the extension parameter in the request body, the error goes away.

I fixed the error on line 441 of sdk/src/platform/Platform.ts.

                    const re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]\
+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0\
-9]+\.)+[a-zA-Z]{2,}))$/;
		    if (re.test(String(email).toLowerCase())) {
                       	 body.extension = extension;
                    }

@byrnereese did you try specifying extension = undefined explicitly? Such as rc.login({extension: undefined}).

@tylerlong I just tried this. It did not work.

Hi Tyler @tylerlong this is going to be a headache for developers/partners once they start to use our SDK for RingCentral Video API's. Can you please double-check the fix you suggested? I'll try it as well and share my comments here. Btw it was news to me that we can log in using email as well, I'll add that in the documentation and in code snippets as currently we only show phone numbers which not all ISV partners have or may have. Thanks

@embbnux Did you have the chance to create a PR? I remember we talked about this in a Glip group.

@embbnux could you please have a look at this? Thanks

Update: I was able to leave the extension string empty and using the node.js SDK and my email as login, was able to create a bridge meeting for RCV without getting any error.