Azure Token Question About Backend Authentication

I seem to find in every part of stack overflow,
any tutorial

that azure must be log in, before I get the code to access the refresh token

const config = {
auth: {
    clientId: process.env.CLIENT_ID,
    authority: process.env.AUTHORITY,
    clientSecret: process.env.CLIENT_SECRET
},
system: {
    loggerOptions: {
        loggerCallback(loglevel, message, containsPii) {
            console.log(message);
        },
        piiLoggingEnabled: false,
        logLevel: msal.LogLevel.Verbose,
       }
   }
};
const authCodeUrlParameters = {
scopes: ["user.read","user.write"],
redirectUri: process.env.REDIRECT_URL,
};

pca.getAuthCodeUrl(authCodeUrlParameters).then((response) => {
// res.redirect(response);
console.log(response);
}).catch((error) => console.log(JSON.stringify(error)));
console.log(authCodeUrlParameters);
const pca = new msal.ConfidentialClientApplication(config);
app.get('/redirect', (req, res) => {
const tokenRequest = {
    code: req.query.code,
    scopes: ["user.read"],
    redirectUri: REDIRECT_URI,
};

pca.acquireTokenByCode(tokenRequest).then((response) => {
    console.log("nResponse: n:", response);
    res.sendStatus(200);
}).catch((error) => {
    console.log(error);
    res.status(500).send(error);
});
});

getAuthCodeUrl returns a link which I would need to login to get my code
which then would I need to use to get the tokens and have my refresh token there.

but I don’t want to access the link since I’m using console not GUI,

My Mind is at the breaking point I don’t know what to do.
I just need the API for One Drive,
so I can Upload my file.

majority in the stackoverflow,
has a code that requires a refresh token

I can’t get the refresh token without accessing the link.

Any help?