Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

185
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda