# renewAuth Timeout err (Silent Auth) to custom page

**URL:** <https://community.auth0.com/t/renewauth-timeout-err-silent-auth-to-custom-page/6998>\
**Category:** Get Help\
**Tags:** renewauth, custom-login, silent-auth\
**Created:** [June 9, 2017, 7:12pm UTC](https://community.auth0.com/t/renewauth-timeout-err-silent-auth-to-custom-page/6998 "2017-06-09T19:12:12Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![cgarcia](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@cgarcia](https://community.auth0.com/u/cgarcia)\
**Post date:** [June 9, 2017, 7:12pm UTC](https://community.auth0.com/t/renewauth-timeout-err-silent-auth-to-custom-page/6998/1 "2017-06-09T19:12:12Z")

</div>

Keep getting a timeout on err using `renewAuth`. The logic I am going for is to check if the user is currently login, if so, hash the token/get user info else redirect to custom login page (on error).

What am I missing? I have the callback URL set up and am able to get user info if I force feed it a valid token via hash.

`index.html`

```
window.addEventListener('load', function () {
    var webAuth = new auth0.WebAuth({
        domain: AUTH0_DOMAIN,
        clientID: AUTH0_CLIENT_ID,
        redirectUri: 'http://localhost:56517',
        responseType: 'token id_token',
        scope: 'openid'
    });

    function checkUser() {
        webAuth.parseHash(function (err, authResult) {
            if (authResult && authResult.accessToken && authResult.idToken) {
                //Get User info function
            } else {
                debugger;
                webAuth.renewAuth({
                    redirectUri: '/silent-callback.html',
                    usePostMessage: true
                }, function (err, authResult) {
                    debugger;
                    if (err) {
                        //redirect to custom login page
                    }
                    else {
                        window.location.hash = authResult.idToken;
                        //Get User info function
                    }
                });
            }
        });
    }
    checkUser();
})`

```

`silent-callback.html`

```
<script src="https://cdn.auth0.com/js/auth0/8.0.4/auth0.min.js"></script>
<script type="text/javascript">
  var webAuth = new auth0.WebAuth({
    domain: AUTH0_DOMAIN,
    clientID: AUTH0_CLIENT_ID
  });
    var result = webAuth.parseHash(window.location.hash, function (err, data) {
        parent.postMessage(err || data, "http://localhost:56517/index.html");
  });
</script>

```

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [June 9, 2017, 8:07pm UTC](https://community.auth0.com/t/renewauth-timeout-err-silent-auth-to-custom-page/6998/2 "2017-06-09T20:07:42Z")

</div>

Could not reproduce your exact error in a test harness containing the exact sample code you provided so there may be an issue outside of what you have shown.

**However, there’s an error (incompleteness) in the logic you presented that may or may not be the cause of the overall issues you’re seeing**, but needs to be fixed nonethless.

The section:

```
if (err) {
  // redirect to custom login page
} else { /* ... */ }

```

should instead be:

```
// authResult.error could mean the user does not have an active session
// so it should also require a redirect to the login page
if (err || authResult.error) {
  // redirect to custom login page
} else { /* ... */ }

```

---

<div class="post-metadata">

**Author:** ![cgarcia](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@cgarcia](https://community.auth0.com/u/cgarcia)\
**Post date:** [June 9, 2017, 8:50pm UTC](https://community.auth0.com/t/renewauth-timeout-err-silent-auth-to-custom-page/6998/3 "2017-06-09T20:50:39Z")

</div>

Thank you for the additional error catching. Are there any settings that you suggest looking at that is associated that may be missing? I have set Callback URL and CORS.

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [June 12, 2017, 6:07pm UTC](https://community.auth0.com/t/renewauth-timeout-err-silent-auth-to-custom-page/6998/4 "2017-06-12T18:07:34Z")

</div>

At first glance I would say no, besides the situation already pointed out I used your sample code without issues and also only had to ensure the proper callback URL’s were in place.

---

<div class="post-metadata">

**Author:** ![cgarcia](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@cgarcia](https://community.auth0.com/u/cgarcia)\
**Post date:** [June 24, 2017, 3:54am UTC](https://community.auth0.com/t/renewauth-timeout-err-silent-auth-to-custom-page/6998/5 "2017-06-24T03:54:27Z")

</div>

Realize that line 17, redirecturi, need the full address to work correctly. Now for renewAuth, I am always getting login\_required. Found a github using the similar logic that I am at: [https://github.com/rochdev/auth0-nonce-bug](https://github.com/rochdev/auth0-nonce-bug)

They have a comment of the following: “Configure an identity provider with a client ID and client secret in Auth0 (otherwise you will always get login\_required)”

Seems like it’s possible that I do not have this step set up correctly. What does this statement actually mean?

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [June 26, 2017, 8:42pm UTC](https://community.auth0.com/t/renewauth-timeout-err-silent-auth-to-custom-page/6998/6 "2017-06-26T20:42:07Z")

</div>

The `login_required` is an expected situation that means there was no previously authenticated session for the user. In order for silent authentication to succeed the user must have previously authenticated in a way that generated an authenticated session; if the user went through the hosted login page then it’s highly likely that the session was generated so renewing auth using the same browser would be able to leverage that session and succeed. In relation to the sentence in the linked repo, I’m honestly not sure what they wanted to mean with that.

---

<div class="post-metadata">

**Author:** ![marcsyp](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@marcsyp](https://community.auth0.com/u/marcsyp)\
**Post date:** [August 13, 2017, 12:17pm UTC](https://community.auth0.com/t/renewauth-timeout-err-silent-auth-to-custom-page/6998/7 "2017-08-13T12:17:39Z")

</div>

Did you get this working? I am having a very difficult time getting this to work in an Ionic 2 application. Everybody in the forums seems to understand perfectly how to set the redirect Uri properly – “all I had to do was set the redirect Uri properly” – but that’s the part that is tripping me up. I have tried “[http://localhost/silent-callback.html](http://localhost/silent-callback.html)”, “[http://localhost/pages/silent-callback/silent-callback.html](http://localhost/pages/silent-callback/silent-callback.html)”, etc. But can’t find the right Uri. Any thoughts?

---

<div class="post-metadata">

**Author:** ![marcsyp](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@marcsyp](https://community.auth0.com/u/marcsyp)\
**Post date:** [August 13, 2017, 12:18pm UTC](https://community.auth0.com/t/renewauth-timeout-err-silent-auth-to-custom-page/6998/8 "2017-08-13T12:18:43Z")

</div>

And how do you generate a proper callback URL? My silent-callback page is in src/pages/silent-callback/silent-callback.html, but I can’t get it to fire.

Thanks,  
Marc

---

<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:** [March 2, 2018, 5:54am UTC](https://community.auth0.com/t/renewauth-timeout-err-silent-auth-to-custom-page/6998/9 "2018-03-02T05:54:32Z")

</div>


