How to use the @azure/ms-rest-js.promiseToCallback function in @azure/ms-rest-js

To help you get started, we’ve selected a few @azure/ms-rest-js 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 / ms-rest-nodeauth / lib / login.ts View on Github external
export function interactive(options?: InteractiveLoginOptions, callback?: { (err: Error, credentials: DeviceTokenCredentials, subscriptions: Array): void }): any {
  if (!callback && typeof options === "function") {
    callback = options;
    options = undefined;
  }
  const cb = callback as Function;
  if (!callback) {
    return withInteractiveWithAuthResponse(options).then((authRes) => {
      return Promise.resolve(authRes.credentials);
    }).catch((err) => {
      return Promise.reject(err);
    });
  } else {
    msRest.promiseToCallback(withInteractiveWithAuthResponse(options))((err: Error, authRes: AuthResponse) => {
      if (err) {
        return cb(err);
      }
      return cb(undefined, authRes.credentials, authRes.subscriptions);
    });
  }
}
github Azure / ms-rest-nodeauth / lib / login.ts View on Github external
export function loginWithAppServiceMSI(options?: MSIAppServiceOptions | Callback, callback?: Callback): void | Promise {
  if (!callback && typeof options === "function") {
    callback = options;
    options = {};
  }
  const cb = callback as Function;
  if (!callback) {
    return _withAppServiceMSI(options as MSIAppServiceOptions);
  } else {
    msRest.promiseToCallback(_withAppServiceMSI(options as MSIAppServiceOptions))((err: Error, tokenRes: MSITokenResponse) => {
      if (err) {
        return cb(err);
      }
      return cb(undefined, tokenRes);
    });
  }
}
github Azure / ms-rest-nodeauth / lib / login.ts View on Github external
export function withAuthFile(options?: LoginWithAuthFileOptions, callback?: { (err: Error, credentials: ApplicationTokenCredentials, subscriptions: Array): void }): any {
  if (!callback && typeof options === "function") {
    callback = options;
    options = undefined;
  }
  const cb = callback as Function;
  if (!callback) {
    return withAuthFileWithAuthResponse(options).then((authRes) => {
      return Promise.resolve(authRes.credentials);
    }).catch((err) => {
      return Promise.reject(err);
    });
  } else {
    msRest.promiseToCallback(withAuthFileWithAuthResponse(options))((err: Error, authRes: AuthResponse) => {
      if (err) {
        return cb(err);
      }
      return cb(undefined, authRes.credentials, authRes.subscriptions);
    });
  }
}
github Azure / ms-rest-nodeauth / lib / login.ts View on Github external
export function withUsernamePassword(username: string, password: string, options?: LoginWithUsernamePasswordOptions, callback?: { (err: Error, credentials: UserTokenCredentials, subscriptions: Array): void }): any {
  if (!callback && typeof options === "function") {
    callback = options;
    options = undefined;
  }
  const cb = callback as Function;
  if (!callback) {
    return withUsernamePasswordWithAuthResponse(username, password, options).then((authRes) => {
      return Promise.resolve(authRes.credentials);
    }).catch((err) => {
      return Promise.reject(err);
    });
  } else {
    msRest.promiseToCallback(withUsernamePasswordWithAuthResponse(username, password, options))((err: Error, authRes: AuthResponse) => {
      if (err) {
        return cb(err);
      }
      return cb(undefined, authRes.credentials, authRes.subscriptions);
    });
  }
}
github Azure / ms-rest-nodeauth / lib / login.ts View on Github external
export function loginWithVmMSI(options?: MSIVmOptions | Callback, callback?: Callback): void | Promise {
  if (!callback && typeof options === "function") {
    callback = options;
    options = {};
  }
  const cb = callback as Function;
  if (!callback) {
    return _withMSI(options as MSIVmOptions);
  } else {
    msRest.promiseToCallback(_withMSI(options as MSIVmOptions))((err: Error, tokenRes: MSITokenResponse) => {
      if (err) {
        return cb(err);
      }
      return cb(undefined, tokenRes);
    });
  }
}
github Azure / ms-rest-nodeauth / lib / login.ts View on Github external
export function withServicePrincipalCertificate(clientId: string, certificateStringOrFilePath: string, domain: string, options?: AzureTokenCredentialsOptions, callback?: { (err: Error, credentials: ApplicationTokenCertificateCredentials, subscriptions: Array): void }): any {
  if (!callback && typeof options === "function") {
    callback = options;
    options = undefined;
  }
  const cb = callback as Function;
  if (!callback) {
    return withServicePrincipalCertificateWithAuthResponse(clientId, certificateStringOrFilePath, domain, options).then((authRes) => {
      return Promise.resolve(authRes.credentials);
    }).catch((err) => {
      return Promise.reject(err);
    });
  } else {
    msRest.promiseToCallback(withServicePrincipalCertificateWithAuthResponse(clientId, certificateStringOrFilePath, domain, options))((err: Error, authRes: AuthResponse) => {
      if (err) {
        return cb(err);
      }
      return cb(undefined, authRes.credentials, authRes.subscriptions);
    });
  }
}
github Azure / ms-rest-nodeauth / lib / login.ts View on Github external
export function withServicePrincipalSecret(clientId: string, secret: string, domain: string, options?: AzureTokenCredentialsOptions, callback?: { (err: Error, credentials: ApplicationTokenCredentials, subscriptions: Array): void }): any {
  if (!callback && typeof options === "function") {
    callback = options;
    options = undefined;
  }
  const cb = callback as Function;
  if (!callback) {
    return withServicePrincipalSecretWithAuthResponse(clientId, secret, domain, options).then((authRes) => {
      return Promise.resolve(authRes.credentials);
    }).catch((err) => {
      return Promise.reject(err);
    });
  } else {
    msRest.promiseToCallback(withServicePrincipalSecretWithAuthResponse(clientId, secret, domain, options))((err: Error, authRes: AuthResponse) => {
      if (err) {
        return cb(err);
      }
      return cb(undefined, authRes.credentials, authRes.subscriptions);
    });
  }
}