# Auth0 React.js Invalid State on getAccessTokenWithPopup() method

**URL:** <https://community.auth0.com/t/auth0-react-js-invalid-state-on-getaccesstokenwithpopup-method/75203>\
**Category:** Get Help\
**Tags:** jwt, api, access-token, login, auth0\
**Created:** [December 20, 2021, 7:14am UTC](https://community.auth0.com/t/auth0-react-js-invalid-state-on-getaccesstokenwithpopup-method/75203 "2021-12-20T07:14:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![snurfer0](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/snurfer0/32/33018_2.png) [@snurfer0](https://community.auth0.com/u/snurfer0)\
**Post date:** [December 20, 2021, 7:14am UTC](https://community.auth0.com/t/auth0-react-js-invalid-state-on-getaccesstokenwithpopup-method/75203/1 "2021-12-20T07:14:03Z")

</div>

I am trying to access the token with pop up using `getAccessTokenWithPopup` method.

```auto
export const getApiAccessToken = async getAccessTokenWithPopup => {
    const audience = "http://localhost/8000"
    let token = await getAccessTokenWithPopup({
        audience: audience,
        scope: "read_write:all"
    }).catch(err => console.error(err))
    console.log(token)

```

The method catches this error and the token is undefined.

```auto
index.js:1 Error: Invalid state
    at e.<anonymous> (auth0-spa-js.production.esm.js:15)
    at auth0-spa-js.production.esm.js:15
    at Object.next (auth0-spa-js.production.esm.js:15)
    at a (auth0-spa-js.production.esm.js:15)

```

It worked well a few hours ago, something screwed up.

update --------------  
after some time of debugging this error appears

```auto
Error: Service not found: http://localhost:8000/

```

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [December 23, 2021, 5:10pm UTC](https://community.auth0.com/t/auth0-react-js-invalid-state-on-getaccesstokenwithpopup-method/75203/3 "2021-12-23T17:10:54Z")

</div>

Hi @snurfer0,

> [@snurfer0](#):
>
> after some time of debugging this error appears
> 
> ```auto
> Error: Service not found: http://localhost:8000/
> 
> ```

If I remember correctly, this error means the _identifier_ parameter you passed as the _audience_ is not linked to an API you have registered in the dashboard. Check out this FAQ for more help on what you should pass as the audience:

[https://community.auth0.com/t/what-is-the-audience/71414](https://community.auth0.com/t/what-is-the-audience/71414)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [January 7, 2022, 5:10pm UTC](https://community.auth0.com/t/auth0-react-js-invalid-state-on-getaccesstokenwithpopup-method/75203/4 "2022-01-07T17:10:56Z")

</div>

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.
