Skip to Content
0
Jun 04, 2020 at 06:40 PM

Problem with fetching variables and credentials from Cloud Factory

358 Views

Hi,

I'm facing some issues with fetching variables and credentials from Cloud Factory. Everything worked fine for a while, but recently code stop working properly. I use the code provided by SAP in a blog post regarding Cloud Factory variables. When the code below is executed, 'Username fetch failed' message is logged. Do you have any idea why is that? Did SAP change anything in Cloud Factory API, so that this code should not work now for any reason? Of course, all variables and credentials exist in Cloud Factory environment.

Thanks!

var credDeclaration = {}; credDeclaration["XYZ"] = 
 {
    server: true
 }
 ctx.cryptography.credential(credDeclaration);
 //////////
ctx.cryptography.credentials["XYZ"].get(function (code, label, credential)  
{
   if (code === e.error.OK) 
   {
      sc.localData.cred =  
      {
          username : credential.userName.get(),
          password : credential.password.get()
      }
			rootData_Main.password=sc.localData.cred.password;
			rootData_Main.user_name=sc.localData.cred.username;
      ctx.log("LOGIN: " +sc.localData.cred.username);					
 }
 else 
 {				
	ctx.log("Username fetch failed");
 }
});