News & Announcements User Community Developer Community

Welcome to the RingCentral Community

Please note the community is currently under maintenance and is read-only.

Search
Make sure to review our Terms of Use and Community Guidelines.
  Please note the community is currently under maintenance and is read-only.
Home » Developers
CORS error when trying to login
Tags: getting started
Jan 21, 2021 at 1:28am   •   1 replies  •  0 likes
Martin Ingham

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>


1 Answer
answered on Jan 21, 2021 at 9:10am  

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.


 0



A new Community is coming to RingCentral!

Posts are currently read-only as we transition into our new platform.

We thank you for your patience
during this downtime.

Try Workflow Builder

Did you know you can easily automate tasks like responding to SMS, team messages, and more? Plus it's included with RingCentral Video and RingEX plans!

Try RingCentral Workflow Builder

PRODUCTS
RingEX
Message
Video
Phone
OPEN ECOSYSTEM
Developer Platform
APIs
Integrated Apps
App Gallery
Developer support
Games and rewards

RESOURCES
Resource center
Blog
Product Releases
Accessibility
QUICK LINKS
App Download
RingCentral App login
Admin Portal Login
Contact Sales
© 1999-2024 RingCentral, Inc. All rights reserved. Legal Privacy Notice Site Map Contact Us