How to use the @azure/core-amqp.Constants.aadServiceBusScope function in @azure/core-amqp

To help you get started, we’ve selected a few @azure/core-amqp 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 / servicebus / service-bus / src / core / linkEntity.ts View on Github external
this.name,
      this.address
    );
    await defaultLock.acquire(this._context.namespace.cbsSession.cbsLock, () => {
      return this._context.namespace.cbsSession.init();
    });

    let tokenObject: AccessToken;
    let tokenType: TokenType;
    if (this._context.namespace.tokenCredential instanceof SharedKeyCredential) {
      tokenObject = this._context.namespace.tokenCredential.getToken(this.audience);
      tokenType = TokenType.CbsTokenTypeSas;
      // renew sas token in every 45 minutess
      this._tokenTimeout = (3600 - 900) * 1000;
    } else {
      const aadToken = await this._context.namespace.tokenCredential.getToken(Constants.aadServiceBusScope);
      if (!aadToken) {
        throw new Error(`Failed to get token from the provided "TokenCredential" object`);
      }
      tokenObject = aadToken;
      tokenType = TokenType.CbsTokenTypeJwt;
      this._tokenTimeout = tokenObject.expiresOnTimestamp - Date.now() - 2 * 60 * 1000;
    }
    
    log.link(
      "[%s] %s: calling negotiateClaim for audience '%s'.",
      this._context.namespace.connectionId,
      this._type,
      this.audience
    );
    // Acquire the lock to negotiate the CBS claim.
    log.link(