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

133
Visualizações
Initialise Azure Application Client in TypeScript

New to Typescript and still getting used to Microsoft Azure so please excuse the basic question.

I have created an Enterprise Application which should be able to log into the Graph API and read a user profile. I have the client id/secret , tenant id but I need to know how to initialise this client within TypeScript.

Am i supposed to initialise a GraphClient or is there a a generic Client I can use?

A link to a tutorial/example or documentation on how to do this would be amazing.

For context I want to be able to write one function to initialise the client and subsequently write the query- all the docs talk about multiple files which I cannot utilise because I am writing this as a third party integration.

I have found this but it seems very complex and I can't really follow it.

Is there a typescript equivalent of

client_credential = ClientSecretCredential(tenant_id, client_id, client_secret)
client = GraphClient(credential=self.client_credential,
                     scopes=['https://graph.microsoft.com/.default']
)
almost 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

This is the way I've managed to do it. I'm bounded by using an extremely old version of the microsoft graph module unfortunately.

   const qs = require('qs');
   const MicrosoftGraphClient = require('@microsoft/microsoft-graph-client@1.0.0');
   const axios = require('axios@0.27.2');
   
   
   const getToken = async () => {
      try{
         const response = await axios.post(
        `https://login.microsoftonline.com/${tenantId}/oauth2/v2.0/token`,
         qs.stringify(
            {
               client_id : clientId,
               client_secret: clientSecret,
               scope: 'https://graph.microsoft.com/.default',
               grant_type: 'client_credentials'
            }
         ))

         let tokenSet = response.data;
         
         return tokenSet.access_token;
      } catch (error){
      console.log(error)
   };
      
  }

   var client = MicrosoftGraphClient.Client.init({
      authProvider: async (done) => {
         const token = await getToken()
         done(null, token);
      }
   });
almost 4 years ago · Santiago Trujillo 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