Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

CORS Error while fetching access token from HMRC

Former Member
0 Likes
638

I am trying to fetch access token from HMRC Sandbox API. The below code works completely fine when I test it from my web IDE. But it doesn't work as the same in the client's system. The only difference in code is the redirect URI in the client system which is also a HTTPS link. I cannot disable web security or add CORS plugin. Is there any other way to fix this issue?

<code>var postQuery ={};
postQuery.code = that.code;
postQuery.client_id = that.getView().getModel("appView").getProperty("/clientID");
postQuery.client_secret = that.getView().getModel("appView").getProperty("/clientSecret");
postQuery.grant_type ="authorization_code";
postQuery.redirect_uri ="https://webidetesting4631275-p*******trial.dispatcher.hanatrial.ondemand.com/webapp/index.html?hc_orionpath=/DI_webide_di_workspaceletjq4u76joab5p6/Run_Reports";
$.post("https://test-api.service.hmrc.gov.uk/oauth/token", postQuery,function(data){
  console.log(data);});
<code><img src="https://answers.sap.com/storage/temp/1731534-error.png"><br>

I am trying to fetch access token from HMRC Sandbox API. The below code works completely fine when I test it from my web IDE. But it doesn't work as the same in the client's system. The only difference in code is the redirect URI in the client system which is also a HTTPS link. I cannot disable web security or add CORS plugin. Is there any other way to fix this issue?

<code>var postQuery ={};
postQuery.code = that.code;
postQuery.client_id = that.getView().getModel("appView").getProperty("/clientID");
postQuery.client_secret = that.getView().getModel("appView").getProperty("/clientSecret");
postQuery.grant_type ="authorization_code";
postQuery.redirect_uri ="https://webidetesting4631275-p*******trial.dispatcher.hanatrial.ondemand.com/webapp/index.html?hc_orionpath=/DI_webide_di_workspaceletjq4u76joab5p6/Run_Reports";
$.post("https://test-api.service.hmrc.gov.uk/oauth/token", postQuery,function(data){
  console.log(data);});
<code><img src="https://answers.sap.com/storage/temp/1731534-error.png"><br>
0 REPLIES 0