# ESI Refresh Token

**URL:** <https://forums.eveonline.com/t/esi-refresh-token/293260>\
**Category:** Third Party Developers\
**Tags:** esi\
**Created:** [February 2, 2021, 11:22am UTC](https://forums.eveonline.com/t/esi-refresh-token/293260 "2021-02-02T11:22:50Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![IronSoul](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/ironsoul/32/254335_2.png) [@IronSoul](https://forums.eveonline.com/u/IronSoul)\
**Post date:** [February 2, 2021, 11:22am UTC](https://forums.eveonline.com/t/esi-refresh-token/293260/1 "2021-02-02T11:22:50Z")

</div>

According to [Refreshing tokens | esi-docs](https://docs.esi.evetech.net/docs/sso/refreshing_access_tokens.html)  
“the refresh token can be stored and used indefinitely.”  
This doesn’t appear to be accurate because it appears all of my users refresh tokens become unusable after 30 days?

Using EsiPy + Flask.

```
results = db
refresh_token = results.refresh_token

esisecurity.update_token({
    'access_token': '', # leave this empty
    'expires_in': -1, # seconds until expiry, so we force refresh anyway
    'refresh_token': refresh_token
})
try:
    op = esiapp.op['get_characters_character_id_skills'](
        character_id = c_id
    )
    return "PASS"
except:
    return "Refresh Token Invalid."
```

---

<div class="post-metadata">

**Author:** ![Blacksmoke16](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/blacksmoke16/32/376589_2.png) [@Blacksmoke16](https://forums.eveonline.com/u/Blacksmoke16)\
**Post date:** [February 2, 2021, 2:06pm UTC](https://forums.eveonline.com/t/esi-refresh-token/293260/2 "2021-02-02T14:06:45Z")

</div>

Assuming this is raising an exception, could you include what the response body is? That would include the actual error and tell you what failed.

---

<div class="post-metadata">

**Author:** ![IronSoul](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/ironsoul/32/254335_2.png) [@IronSoul](https://forums.eveonline.com/u/IronSoul)\
**Post date:** [February 2, 2021, 3:41pm UTC](https://forums.eveonline.com/t/esi-refresh-token/293260/3 "2021-02-02T15:41:38Z")

</div>

> esipy.exceptions.APIException: HTTP Error 400: b’{“error”:“invalid\_grant”,“error\_description”:“Invalid refresh token. Token missing/expired.”}’

---

<div class="post-metadata">

**Author:** ![Raes\_Ongrard](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/raes_ongrard/32/249602_2.png) [@Raes\_Ongrard](https://forums.eveonline.com/u/Raes_Ongrard)\
**Post date:** [February 2, 2021, 3:49pm UTC](https://forums.eveonline.com/t/esi-refresh-token/293260/4 "2021-02-02T15:49:49Z")

</div>

Unfortunately, I do not know English well, and programming is even worse. But it seems that this is exactly why 40 scientific accounts, which I logged into once a month, do not work for me now. The support didn’t help me in any way. I contacted two times and both times I was offered, when clearing the cache did not help, re-enter 40 pairs of username and password. Tell me, can I do something in order not to spend 2 days of my life on this once a month?

---

<div class="post-metadata">

**Author:** ![Blacksmoke16](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/blacksmoke16/32/376589_2.png) [@Blacksmoke16](https://forums.eveonline.com/u/Blacksmoke16)\
**Post date:** [February 2, 2021, 4:00pm UTC](https://forums.eveonline.com/t/esi-refresh-token/293260/5 "2021-02-02T16:00:25Z")

</div>

Do you get that same error if you try to refresh it manually, such as via Postman or curl? E.g. following the steps within [Refreshing tokens | esi-docs](https://docs.esi.evetech.net/docs/sso/refreshing_access_tokens.html#web-based-applications).

I brought this up in slack as well.

---

<div class="post-metadata">

**Author:** ![IronSoul](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/ironsoul/32/254335_2.png) [@IronSoul](https://forums.eveonline.com/u/IronSoul)\
**Post date:** [February 2, 2021, 4:36pm UTC](https://forums.eveonline.com/t/esi-refresh-token/293260/6 "2021-02-02T16:36:57Z")

</div>

Having trouble getting this to work.

> curl -XPOST -H “Content-Type:application/x-www-form-urlencoded” -H “Authorization:Basic base64(client:secret)” -d ‘{“grant\_type”:“refresh\_token”, “refresh\_token”: “db refresh token”}’ [https://login.eveonline.com/oauth/token](https://login.eveonline.com/oauth/token)

returns nothing. Not sure what I’m doing wrong.

edit: managed to get unknown grant\_type. hopefully I’ll get there.  
edit #2: application/json returns The refresh token is malformed.

---

<div class="post-metadata">

**Author:** ![Blacksmoke16](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/blacksmoke16/32/376589_2.png) [@Blacksmoke16](https://forums.eveonline.com/u/Blacksmoke16)\
**Post date:** [February 2, 2021, 5:03pm UTC](https://forums.eveonline.com/t/esi-refresh-token/293260/7 "2021-02-02T17:03:45Z")

</div>

You’re passing JSON data, when it should be form data.

From what was said on Slack, it seems that refresh tokens _DO_ expire if they’re not used within a month. This should probably be added to the ESI docs.

As for @Raes_Ongrard, sounds like the solution is to at least start up those characters twice a month.

---

<div class="post-metadata">

**Author:** ![IronSoul](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/ironsoul/32/254335_2.png) [@IronSoul](https://forums.eveonline.com/u/IronSoul)\
**Post date:** [February 2, 2021, 7:09pm UTC](https://forums.eveonline.com/t/esi-refresh-token/293260/8 "2021-02-02T19:09:06Z")

</div>

That makes sense, thanks. Atleast I know I’m not going crazy. 🙂

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/eveonline/original/3X/4/1/41ec4921cbaca7a6f9ea556e7cc20018461eae5e.png) [@system](https://forums.eveonline.com/u/system)\
**Post date:** [May 3, 2021, 7:09pm UTC](https://forums.eveonline.com/t/esi-refresh-token/293260/9 "2021-05-03T19:09:19Z")

</div>

Closed on May 3, 2021, 7:09pm UTC

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