Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

177
Views
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?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I manage to find it, you should find the Client Credentials,

I use request headers https://login.microsoftonline.com/{tenant id}/oauth2/v2.0/token

tenant id is located in app registration in azure

then make sure the grant type is grant_type: 'client_credentials', scope: 'https://graph.microsoft.com/.default' //not sure if this is changeable yet

either use request lib or axios get put post head

hope it helps other people when they find this issue

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!