How to use the @azure/ms-rest-nodeauth.interactiveLoginWithAuthResponse 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 serverless / serverless-azure-functions / src / services / loginService.ts View on Github external
public async interactiveLogin(options?: InteractiveLoginOptions): Promise {
    let authResp: AuthResponse = { credentials: undefined, subscriptions: [] };
    const fileTokenCache = new SimpleFileTokenCache();
    if (fileTokenCache.isEmpty()) {
      await open("https://microsoft.com/devicelogin");
      authResp = await interactiveLoginWithAuthResponse({ ...options, tokenCache: fileTokenCache });
      fileTokenCache.addSubs(authResp.subscriptions);
    } else {
      authResp.credentials = new DeviceTokenCredentials(undefined, undefined, fileTokenCache.first().userId, undefined, undefined, fileTokenCache);
      authResp.subscriptions = fileTokenCache.listSubscriptions();
    }

    return authResp;
  }