Azure Devops Extension (VSTS) Set a variable that needs to be accessed in next task using Javascript

I am trying to access the variable set in one task from another task in javascript. In the first task I am setting the variable as following –

 var connection = tl.getInput("connection", true);
     if(connection !== undefined) {
       var auth = tl.getEndpointAuthorization(connection, false);
      
       let access_key_1 = auth.parameters["password"];
       let username = auth.parameters["username"]; 
      
       if(auth !== undefined) {
       
          console.log('##vso[task.setvariable variable=access_key_1;]', access_key_1);


In the second task i am trying to access the variable –

console.log(access_key_1);

But I am getting error –

ReferenceError: access_key_1 is not defined.