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

125
Views
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 answers
Answer question

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