Closed jync closed 3 years ago
hi @jync, DynamicsWebApi does not depend on ADAL, it just needs a token. It can even be a custom authentication functionality. So, I am not worried about that.
You can preview v2 in typescript
branch, it should be visible to everyone. Some parameters and return objects will most likely change but not too much. So, it should give you an idea what to expect from v2.
anyone have some examples of using the new msal-node? i cant get it to work
I am using this code for my testing (it's TypeScript):
import * as DynamicsWebApi from "dynamics-web-api";
import * as MSAL from "@azure/msal-node";
import Config from "./config";
const authorityUrl = 'https://login.microsoftonline.com/<GUID HERE>';
const msalConfig = {
auth: {
clientId: Config.clientId,
authority: authorityUrl,
clientSecret: Config.secret,
knownAuthorities: ["login.microsoftonline.com"]
}
}
const cca = new MSAL.ConfidentialClientApplication(msalConfig);
//add a callback as a parameter for your function
const acquireToken = (dynamicsWebApiCallback: DynamicsWebApi.OnTokenAcquiredCallback) => {
cca.acquireTokenByClientCredential({
scopes: ["https://<YOURORG>.crm.dynamics.com/.default"]
}).then(response => {
//call DynamicsWebApi callback only when a token has been retrieved
dynamicsWebApiCallback(response.accessToken);
}).catch((error) => {
console.log(JSON.stringify(error));
});
}
const config: DynamicsWebApi.Config = {
webApiUrl: "https://<YOURORG>.crm.dynamics.com/api/data/v9.2/",
onTokenRefresh: acquireToken,
useEntityNames: true
};
const dynamicsWebApi = new DynamicsWebApi(config);
@pixelpaulaus sorry forgot to ping, my reply is above.
that helped a great deal, thanks
glad it helped!
Just planning ahead. I can see v2 is coming and I can see MS is deprecating ADAL.js. What is DynamicsWebApi's timeline on these items? Is there a way we could preview v2?