(ssg-wsg) - Generating Token in application is rejected by CORS policy

325 views Asked by At

I can generate SSG WSG token by using Postman, but I am getting error like "from origin 'myApplication_URL' has been blocked by CORS policy" when I call that API via jQuery Ajax.

How to implement SSG WSG within application.

3

There are 3 answers

3
dao_ying3 On

Are you implementing the API request to be triggered from client's browser, or from your application directly?

It is likely you will get the CORS policy error if you are allowing your client to send the API request directly from their browser. The API request is tied to the credentials of your application, and it should be implemented in that way.

Adding on - please share your request payload and the error stack so that we can have a better idea of what is the issue.

0
Bunny On

Here is my request payload. I send request with Open Authentication type credentials.

enter image description here

Please, share on how to implement with Open Authentication type in a better way, directly from application with JavaScript.

3
zerofreeze On

Based on your code snippet, you are implementing the API call to be triggered via AJAX from your end user's client browser. When your end user clicks the button, his/her browser is the client initiating the API call.

For API integrations, it is usually server-to-server calls. Your server application needs to be the one initiating the API call.

SSG Developer Portal had some sample codes for Open Authentication type, using Node.js. https://github.com/ssg-wsg/community/tree/master/guides/open That kind of implementation would be a server-to-server API call.