How to use the @azure/core-auth.isTokenCredential function in @azure/core-auth

To help you get started, we’ve selected a few @azure/core-auth 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 / core / core-http / lib / serviceClient.ts View on Github external
) {
    if (!options) {
      options = {};
    }

    this._withCredentials = options.withCredentials || false;
    this._httpClient = options.httpClient || new DefaultHttpClient();
    this._requestPolicyOptions = new RequestPolicyOptions(options.httpPipelineLogger);

    let requestPolicyFactories: RequestPolicyFactory[];
    if (Array.isArray(options.requestPolicyFactories)) {
      logger.info("ServiceClient: using custom request policies");
      requestPolicyFactories = options.requestPolicyFactories;
    } else {
      let authPolicyFactory: RequestPolicyFactory | undefined = undefined;
      if (isTokenCredential(credentials)) {
        logger.info(
          "ServiceClient: creating bearer token authentication policy from provided credentials"
        );
        // Create a wrapped RequestPolicyFactory here so that we can provide the
        // correct scope to the BearerTokenAuthenticationPolicy at the first time
        // one is requested.  This is needed because generated ServiceClient
        // implementations do not set baseUri until after ServiceClient's constructor
        // is finished, leaving baseUri empty at the time when it is needed to
        // build the correct scope name.
        const wrappedPolicyFactory: () => RequestPolicyFactory = () => {
          let bearerTokenPolicyFactory: RequestPolicyFactory | undefined = undefined;
          let serviceClient = this;
          return {
            create(nextPolicy: RequestPolicy, options: RequestPolicyOptions): RequestPolicy {
              if (bearerTokenPolicyFactory === undefined) {
                bearerTokenPolicyFactory = bearerTokenAuthenticationPolicy(

@azure/core-auth

Provides low-level interfaces and helper methods for authentication in Azure SDK

MIT
Latest version published 23 days ago

Package Health Score

84 / 100
Full package analysis

Popular @azure/core-auth functions