How to use the @azure/ms-rest-nodeauth.loginWithUsernamePassword function in @azure/ms-rest-nodeauth

To help you get started, we’ve selected a few @azure/ms-rest-nodeauth examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Azure / azure-sdk-for-js / sdk / eventhub / event-hubs / samples / loginWithAzureAccount.ts View on Github external
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();
}
github tediousjs / tedious / src / state.ts View on Github external
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);
        }
github Azure / azure-sdk-for-js / sdk / servicebus / service-bus / samples / javascript / gettingStarted / loginWithAzureAccount.js View on Github external
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();
}
github Azure / azure-sdk-for-js / sdk / servicebus / service-bus / samples / typescript / gettingStarted / loginWithAzureAccount.ts View on Github external
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();
}
github tediousjs / tedious / src / connection.js View on Github external
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);