function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
arjun mohanarjun mohan 

Access Token in salesfroce with azure AD

HI All,

My salesforce ORG is SSO Enabled wit Azure AD

Now i need to access Azure Token in my LWC to call other API's hosted in my Azure Org.

 

Thanks

Arjun.M

Best Answer chosen by arjun mohan
arjun mohanarjun mohan

Found answer

Here is the code sample

Http h = new Http();
        HttpRequest req = new HttpRequest();
        req.setEndpoint('https://login.microsoftonline.com/{tenantID}/oauth2/v2.0/token');
        req.setMethod('POST');
        req.setHeader('Content-Type', 'application/x-www-form-urlencoded');
        req.setHeader('Accept', 'application/json');
        req.setBody('grant_type=client_credentials&scope=https%3a%2f%2fgraph.microsoft.com%2f.default&client_id={ClientId}&client_secret={ClientSecret}');
        HttpResponse res = h.send(req);
        if(res.getStatusCode()!=200) {
        }
System.debug('res is>>'+res.getBody());