CORS in Ionic and third party api(Smartsheet)

I am trying to get data from smartsheet API. When I use postman and nodejs in separate server code, it works.

But if I use the API inside the Ionic with HttpClient (@angular/http) it gives CORS issue with run in browser.

Failed to load https://api.smartsheet.com/2.0/sheets/1235941564208899972: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8100' is therefore not allowed access.

 

Comments

  • Hi Gopala,

    That looks like an issue with your API key not working in Iconic (or possibly HTTPClient, not sure where the issue would be).

    The OAuth flow header isn't being included in your response, so it considers your call out of scope. Details on OAuth flow and access scopes can be found here: https://smartsheet-platform.github.io/api-docs/#overview

    I'd recommend reviewing the API key you're using, make sure it's carrying over correctly, and possibly generate a different API key from your account to troubleshoot. You can generate API keys with the following steps:

    1. Sign in to your Smartsheet account on a browser.
    2. Click your profile icon and select Apps & Integration > API Access.
    3. Click the Generate new access token button and give your new token a name so you know what it's being used for.
    4. Copy and paste that new token into your API access header.

    If you continue to experience issues, please reach out to our Support team to troubleshoot further.