title: Auth0 "service not found" error
body: <p>I'm attempting to use Auth0 to issue JWT tokens for accessing my API (so that Auth0 handles all the OAuth and security concerns, etc., and my API just needs to check the token). When I try to test the Authorization Code flow for clients to receive an access token (using Node + Express), the following happens:</p>
  
  <ul>
  <li><p>The authorization code request works fine, and the client is redirected back to my redirect_uri with the code appended to the query. All good.</p></li>
  <li><p>The token request then always fails. If I include the <code>audience</code> parameter, the request returns an <code>access_denied</code> error with the following details: <code>Service not found: {the audience parameter}</code>, regardless of what value I set for the <code>audience</code> parameter.</p></li>
  <li><p>If I don't include the <code>audience</code> parameter, I get a <code>server_error</code> with the message <code>Service not found: https://oauth.auth0.com/userinfo</code>.</p></li>
  </ul>
  
  <p>I've checked every Auth0 setting and read every documentation page thoroughly, and so far nothing has worked. I've also tested the Authorization Code flow in Auth0's API debugger, and it worked fine. My test follows exactly the same parameters, and yet still receives an error requesting the token. I'm testing on localhost. The client credentials and implicit flows are working fine.</p>
  
  <p>Here is a test endpoint I created which retrieves the authorization code from Auth0:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const qs = require('querystring');
  
  const getCode = (req, res) =&gt; {
    const params = {
      audience,                            // the value of the API Audience setting for the client
      client_id,                           // the client ID
      redirect_uri,                        // the redirect_uri, which is also listed in the Allowed Callback URLs field
      response_type: `code`,
      scope:         `offline_access open` // ask to return ID token and refresh token,
      state:         `12345`,
    };
  
    const authDomain = `mydomain.auth0.com/oauth`;
    
    res.redirect(`${authDomain}/oauth/authorize?${qs.stringify(params)}`);
  
  };</code></pre>
  </div>
  </div>
  </p>
  
  <p>The <code>redirect_uri</code> then redirects to the following endpoint, where I make the request for the access token:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const https = require('https');
  
  const callback = (req, res) =&gt; {
  
    const body = {
      client_id,
      client_secret,
      code:          req.query.code,
      grant_type:    `authorization_code`,
      redirect_uri,  // same value as provided during the code request
    };
    
    const opts = {
      headers:  { 'Content-Type': `application/json` },
      hostname: `mydomain.auth0.com`,
      method:   `POST`,
      path:     `/oauth/token`,
    };
    
    const request = https.request(opts, response =&gt; {
      let data = ``;
      response.on(`data`, chunk =&gt; { data += chunk; });
      response.on(`error`, res.send(err.message));
      response.on(`end`, () =&gt; res.json(JSON.parse(data))); // this executes, but displays the error returned from Auth0
    });
    
    request.on(`error`, err =&gt; res.send(err.message));
    request.end(JSON.stringify(body), `utf8`);
  
  };</code></pre>
  </div>
  </div>
  </p>
  
  <p>Any suggestions as to what I might be doing wrong?</p>