Skip to Main Content

Cloud Platform

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

401 Unauthorised error While calling MCS API in Ionic 3

3505659Jul 20 2017 — edited Jul 24 2017

Hi,

I have developed an application for connecting cordova mcs client sdk in Ionic 3 but unfortunately I got unauthorised 401 error

I have followed the steps given  below to call mcs API

declare var mcs:any;

var backend;

var mcs_config = {

  "logLevel": mcs.LOG_LEVEL,

  "logHTTP": true,

  "mobileBackends": {

   "CUST_FW_SCREEN_MB1.0": {

   "default": true,

   "baseUrl": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",

   "applicationKey": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",

   "analytics": {

   "location": true

  },

   "authorization": {

   "basicAuth": {

   "backendId": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",

   "anonymousToken": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

  }

  }

  }

  }

}

then I have intialised mcs like this

constructor(public http: Http) {

   console.log('Hello SampleProvider Provider');

  }

initializeMCS(){

   mcs.mobileBackendManager.platform = new mcs.CordovaPlatform();

   mcs.mobileBackendManager.setConfig(mcs_config);

   backend = mcs.mobileBackendManager.getMobileBackend("CUST_FW_SCREEN_MB1.0");

   console.log("Initialize mcs");

   if(backend != null){

  

   backend.setAuthenticationType("basicAuth");

  }

  }

So then I called this function by passing user name and password

   login(username, password){

   this.initializeMCS();

  return backend.authorization.authenticate(username, password).then((data)=>{

   console.log(data);

  }).catch((error)=>{

   console.log("error");

  });

I have passed the username and password to connect with the MCS

logIn(){

   this.sample.login("XXXXXXXXXXXX", "XXXXXXXXX");

}

But I am getting unauthorised error 401

Can you suggest any methods to resolve the issue

Thank You

Comments