How to use the ms-rest-azure.DeviceTokenCredentials function in ms-rest-azure

To help you get started, we’ve selected a few ms-rest-azure 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 lostintangent / azjs / lib / AzureClient / Authentication.js View on Github external
function createServicePrincipal(credentials, tenantId, subscriptionId) {
    const credOptions = {
        domain: tenantId,
        tokenAudience: "graph",
        username: credentials.username,
        tokenCache: credentials.tokenCache,
        environment: credentials.environment
    };

    const credsForGraph = new azureRest.DeviceTokenCredentials(credOptions);
    const graphClient = new graph(credsForGraph, tenantId);
    const spPass = azureRest.generateUuid();
    const spName = `http://${azureRest.generateUuid()}.azjs.com`;
    const appOptions = {
        availableToOtherTenants: false,
        displayName: "azjs",
        homepage: spName,
        identifierUris: [spName],
        passwordCredentials: [{
            startDate: moment().toISOString(),
            endDate: moment().add(1, "month").toISOString(),
            keyId: azureRest.generateUuid(),
            value: spPass
        }]
    };
github lostintangent / azjs / packages / az-login / index.js View on Github external
function createCredentials(baseCredentials, tenantId, graphToken = false) {
  const credentialOptions = {
    domain: tenantId,
    username: baseCredentials.username,
    tokenCache: baseCredentials.tokenCache,
    environment: baseCredentials.environment
  };

  if (graphToken) {
    credentialOptions.tokenAudience = "graph";
  }

  return new azure.DeviceTokenCredentials(credentialOptions);
}