# How to pass audience in passport-auth0 strategy?

**URL:** <https://community.auth0.com/t/how-to-pass-audience-in-passport-auth0-strategy/84551>\
**Category:** Get Help\
**Tags:** passport, nestjs, auth0\
**Created:** [June 3, 2022, 10:13am UTC](https://community.auth0.com/t/how-to-pass-audience-in-passport-auth0-strategy/84551 "2022-06-03T10:13:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Frederic.Meriot](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/frederic.meriot/32/37802_2.png) [@Frederic.Meriot](https://community.auth0.com/u/Frederic.Meriot)\
**Post date:** [June 3, 2022, 10:13am UTC](https://community.auth0.com/t/how-to-pass-audience-in-passport-auth0-strategy/84551/1 "2022-06-03T10:13:44Z")

</div>

Hi,  
I’am using NestJS 8 with passport-auth0. I don’t know how to pass an audience to the strategy to obtain a JWT access-token (instead an opaque one). I’am using this strategy :

```auto
@Injectable()
export class Auth0Strategy extends PassportStrategy(Strategy, 'auth0') {

  constructor() {
    super({
        domain: process.env.AUTH0_DOMAIN,
        clientID: process.env.AUTH0_CLIENT_ID,
        clientSecret: process.env.AUTH0_CLIENT_SECRET,
        callbackURL: process.env.AUTH0_CALLBACK_URL,
        passReqToCallback: true,
        scope: 'openid email profile',
        state: true,
    });
  }

  async validate (req, accessToken, refreshToken, extraParams, profile, done): Promise<any> {
    done(null, {accessToken,profile});
  }
}

```

This strategy works well, but I obtain an opaque access-token (and a JWT id-token). I read in the documentation that to obtain a JWT access-token, I need to pass the “audience”. But if I add an audience property in the constructor, it has no effect. I tried this :

```auto
super({
        domain: process.env.AUTH0_DOMAIN,
        clientID: process.env.AUTH0_CLIENT_ID,
        clientSecret: process.env.AUTH0_CLIENT_SECRET,
        ...
        audience: "my-wonderful-api-identifier"
    });

```

But still having an opaque access-token.

I wonder how do I pass this audience parameter to the strategy.  
Thank you for your help.

---

<div class="post-metadata">

**Author:** ![lihua.zhang](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/lihua.zhang/32/39683_2.png) [@lihua.zhang](https://community.auth0.com/u/lihua.zhang)\
**Post date:** [June 3, 2022, 6:18pm UTC](https://community.auth0.com/t/how-to-pass-audience-in-passport-auth0-strategy/84551/5 "2022-06-03T18:18:50Z")

</div>

Hi @Frederic.Meriot ,

Welcome to the Auth0 Community!

`I wonder how do I pass this audience parameter to the strategy.`

I found the below scripts for getting the access token by specifying the audience id. [Here](https://github.com/auth0/passport-auth0#getting-access-tokens) are the details.

```auto
app.get(
	'/login',
	passport.authenticate('auth0', {audience: 'urn:my-api'}), 
	function (req, res) {
	  res.redirect('/');
	}
);

```

Hope this helps!

---

<div class="post-metadata">

**Author:** ![lihua.zhang](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/lihua.zhang/32/39683_2.png) [@lihua.zhang](https://community.auth0.com/u/lihua.zhang)\
**Post date:** [February 2, 2023, 6:14pm UTC](https://community.auth0.com/t/how-to-pass-audience-in-passport-auth0-strategy/84551/6 "2023-02-02T18:14:13Z")

</div>


