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

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

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 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