onetcenter / web-services-samples

Sample code using O*NET Web Services API
https://services.onetcenter.org/
MIT License
63 stars 26 forks source link

Keyword Search Demo Errors #4

Closed poweigel closed 3 years ago

poweigel commented 3 years ago

Hi, I'm trying to use the Keyword Search Demo and am running into some problems. I've registered the "https://onetcenter.github.io" domain with O*Net and have been provided a corresponding username, but when I try to connect through the demo I get the following error message:

Call to https://services.onetcenter.org/ws/about?client=onetcenter_github_io4 failed with reason: Failed to fetch

And I get a CORS error message in the console (I'm on Google Chrome):

Access to fetch at 'https://services.onetcenter.org/ws/about?client=onetcenter_github_io4' from origin 'https://onetcenter.github.io' has been blocked by CORS policy: 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.

So I installed and activated the "Access-Control-Allow-Origin" plugin to see if that would help. It looks like I am no longer blocked by CORS policy, but instead am getting a 403 forbidden error. That seems to suggest there might be an issue with the permissions on my O*Net account, but I'm not sure how to fix that. Any thoughts?

Hopper262 commented 3 years ago

Hi, thanks for the detailed report! The missing piece is that the account sign-up process is separate from the client-side domain registration. You still need to register "https://onetcenter.github.io" in your account settings. (You can also reach that page by logging in, clicking "Client-side in browser", then clicking "Register domains".) Then deactivate the plugin, and try the demo again.

The separate step may seem strange, but that way you can register multiple domains for the same project, and you can also set your account URL to your own site or app store page even if you don't use Web Services directly there. You can change that account URL by clicking Edit project info on your account page.

poweigel commented 3 years ago

That worked, thanks!

Hopper262 commented 3 years ago

Great to hear! If you run into anything else, feel free to reopen this issue or start a new one. Best wishes on your project!