Auth0-js login() method and expries_in issue

Hi! I’m using auth0-js npm library for embedded auth in my SPA. In order to implement token refresh for SPAs I’ve followed guide:

https://auth0.com/docs/quickstart/spa/react/05-token-renewal

Which helped me to implement the solution.

However, now I need to adjust Access Token expiration time (expire_in callback parameter) and change it from 7200 seconds to anything else, which I’m not able to do. I followed this article to set token lifetime:

https://auth0.com/docs/tokens/set-access-token-lifetime

I still get expire_in=7200 in response, no matter what I change, that is problem #1. Maybe this method is making a call to /co/authenticate? I need a more clear explanation of what happens there.

If I try to pass audience parameter, which I get from Auth0 Management panel, I get an error:

Service not found: https://my-audience-identifier

I would appreciate an explanation of how to set expire_in along with /co/authenticate endpoint (auth0.login() method).

If you don’t use the audience parameter and only specify a scope=openid, the returned access token is only good for requests to the OIDC userinfo endpoint (https://{your_auth0_domain}/userinfo). These types of access tokens have a fixed duration, and that value can’t be changed.

When you want Auth0 to issue access tokens for a custom API you created (see Authentication and Authorization Flows), you’ll use audience={your_api_identifier}. The API identifier is part of the parameters you provide when creating a custom API entry in the dashboard. Another configuration value for custom APIs is the duration of the tokens issued, and this value will affect the expires_in result.

If you are getting “Service not found”, it means that the API identifier provided in the audience parameter does not exist in your Auth0 tenant (there’s no API with that identifier).

Hope this helps.

Thanks @nicolas_sabena for your reply, however API with this identifier does exist and I pointed it in my original question, I get this identifier from manage.auth0.com

Probably, the problem scope is with audience parameter, because I 100% sure that I have a Custom API in the tenant and I’m copying and pasting its identifier.

I will appreciate more details on why “Service not found” can happen.

Many thanks.

Now, when I switched to auth0.client.login() method I get the following error:

“invalid audience specified for password grant exchange”

Can you provide the exact code you are using for the login method, with all the variables values?