Skip to main content

I am only just starting using RingCentral and I am getting this error when attempting to login :

Access to fetch at 'https://platform.devtest.ringcentral.com//restapi/oauth/token' from origin 'http://localhost:51841' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

I am using example code from github.com/ringcentral/ringcentral-js-client

<script type="text/javascript" src="~/Scripts/RingCentral/ringcentral.min.js"></script>

<script type="text/javascript">

var sdk = new RingCentral.SDK({

server: 'https://platform.devtest.ringcentral.com/',

clientId: '<clientid>',

clientSecret: '<clientsecret>'

});

sdk.platform().login({

"username": "<userid>",

"extension": "101",

"password": "<pwd>"

}).then(() => {

console.log("login success");

}).then((accountinfo) => {

console.log("current account info", accountinfo);

}).then(() => {

console.logout("logout success");

}).catch(e => {

console.error("Error", e);

});

</script>


This is a common issue when it comes to security policy of your local environment. You can enable or disable the CORS to solve the problem. Maybe this article would help you understand better before you change that setting. Or simply browse the Internet for more information about CORS.

Back to the RingCentral JS SDK. The quick start section is just a quick reference and it should not be used when using the SDK on the client side. It is because you will expose the user login credentials on your page source code. That method is suitable for using the SDK in the server side only.

Please refer to this JS SDK for more details.


Reply