Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

178
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda