Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function main(): Promise {
const credentials = await loginWithUsernamePassword(username, password, {
tokenAudience: "https://eventhubs.azure.net/"
});
const client = EventHubClient.createFromAadTokenCredentials(evenHubsEndpoint, eventHubsName, credentials);
/*
Refer to other samples, and place your code here
to send/receive events
*/
await client.close();
}
const getToken = (callback: (err: Error | null, accessToken?: string) => void) => {
const getTokenFromCredentials = (err: Error | undefined, credentials: any) => {
if (err) {
return callback(err);
}
credentials.getToken().then((tokenResponse: any) => {
callback(null, tokenResponse.accessToken);
}, callback);
};
if (authentication.type === 'azure-active-directory-password') {
loginWithUsernamePassword(authentication.options.userName, authentication.options.password, {
clientId: '7f98cb04-cd1e-40df-9140-3bf7e2cea4db',
tokenAudience: this.connection.fedAuthInfoToken.spn
}, getTokenFromCredentials);
} else if (authentication.type === 'azure-active-directory-msi-vm') {
loginWithVmMSI({
clientId: authentication.options.clientId,
msiEndpoint: authentication.options.msiEndpoint,
resource: this.connection.fedAuthInfoToken.spn
}, getTokenFromCredentials);
} else if (authentication.type === 'azure-active-directory-msi-app-service') {
loginWithAppServiceMSI({
msiEndpoint: authentication.options.msiEndpoint,
msiSecret: authentication.options.msiSecret,
resource: this.connection.fedAuthInfoToken.spn
}, getTokenFromCredentials);
}
async function main() {
const tokenCreds = await loginWithUsernamePassword(username, password, {
tokenAudience: "https://servicebus.azure.net/"
});
const sbClient = ServiceBusClient.createFromAadTokenCredentials(serviceBusEndpoint, tokenCreds);
/*
Refer to other samples, and place your code here
to create queue clients, and to send/receive messages
*/
await sbClient.close();
}
async function main(): Promise {
const tokenCreds = await loginWithUsernamePassword(username, password, {
tokenAudience: "https://servicebus.azure.net/"
});
const sbClient = ServiceBusClient.createFromAadTokenCredentials(serviceBusEndpoint, tokenCreds);
/*
Refer to other samples, and place your code here
to create queue clients, and to send/receive messages
*/
await sbClient.close();
}
const getToken = (callback) => {
const getTokenFromCredentials = (err, credentials) => {
if (err) {
return callback(err);
}
credentials.getToken().then((tokenResponse) => {
callback(null, tokenResponse.accessToken);
}, callback);
};
if (authentication.type === 'azure-active-directory-password') {
loginWithUsernamePassword(authentication.options.userName, authentication.options.password, {
clientId: '7f98cb04-cd1e-40df-9140-3bf7e2cea4db',
tokenAudience: this.fedAuthInfoToken.spn
}, getTokenFromCredentials);
} else if (authentication.type === 'azure-active-directory-msi-vm') {
loginWithVmMSI({
clientId: authentication.options.clientId,
msiEndpoint: authentication.options.msiEndpoint,
resource: this.fedAuthInfoToken.spn
}, getTokenFromCredentials);
} else if (authentication.type === 'azure-active-directory-msi-app-service') {
loginWithAppServiceMSI({
clientId: authentication.options.clientId,
msiEndpoint: authentication.options.msiEndpoint,
msiSecret: authentication.options.msiSecret,
resource: this.fedAuthInfoToken.spn
}, getTokenFromCredentials);