# ESI: The refresh token is malformed

**URL:** <https://forums.eveonline.com/t/esi-the-refresh-token-is-malformed/312434>\
**Category:** Third Party Developers\
**Created:** [May 19, 2021, 3:55pm UTC](https://forums.eveonline.com/t/esi-the-refresh-token-is-malformed/312434 "2021-05-19T15:55:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Agrikk](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/agrikk/32/273773_2.png) [@Agrikk](https://forums.eveonline.com/u/Agrikk)\
**Post date:** [May 19, 2021, 3:55pm UTC](https://forums.eveonline.com/t/esi-the-refresh-token-is-malformed/312434/1 "2021-05-19T15:55:16Z")

</div>

I am creating a PHP app on a windows box and I wanted to get the basic ESI OAuth flow worked out before I started coding. I’m running into a problem when trying to refresh a token.

Here’s what I am doing:

1. Browse to the following URL:

> [https://login.eveonline.com/oauth/authorize?response\_type=code&redirect\_uri=https://localhost&client\_id=](https://login.eveonline.com/oauth/authorize?response_type=code&redirect_uri=https://localhost&client_id=)[client ID string]&scope=esi-markets.structure\_markets.v1&secret=[secret string]

1. Copy/paste authorization code from URL returned in step 1 and run the following command in CMD window

> curl -XPOST -H “Content-Type:application/json” -H “Authorization:Basic [Base64 encrypted clientID:secret string ending in ==]” -d “{"grant\_type":"authorization\_code", "code":"[code copy/pasted from URL returned in step 1]"}” [https://login.eveonline.com/oauth/token](https://login.eveonline.com/oauth/token)

1. Make a request against [login.eveonline.com](http://login.eveonline.com) in a CMD window

> curl -XGET -H “Authorization: Bearer [authorization token]” [https://login.eveonline.com/oauth/verify](https://login.eveonline.com/oauth/verify)

which returns

> {“CharacterID”:999999999,“CharacterName”:“Player1”,“ExpiresOn”:“2021-05-19T15:58:11”,“Scopes”:“esi-markets.structure\_markets.v1”,“TokenType”:“Character”,“CharacterOwnerHash”:“[hash]”,“IntellectualProperty”:“EVE”}

1. I then want to refresh the token by running this in a CMD window:

> curl -XPOST --header “Accept: application/json” -H “Content-Type:application/x-www-form-urlencoded” -H “Authorization:Basic [Base64 encrypted clientID:secret string ending in ==]” -d “grant\_type=refresh\_token&refresh\_token=[access token returned from step 2]” [https://login.eveonline.com/oauth/token](https://login.eveonline.com/oauth/token)

but this command returns

> {“error”:“invalid\_request”,“error\_description”:“The refresh token is malformed.”}

Clearly the syntax of the command in step 4 is wrong somehow, but I can’t figure it out. Can anyone help?

---

<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:** [May 19, 2021, 4:41pm UTC](https://forums.eveonline.com/t/esi-the-refresh-token-is-malformed/312434/2 "2021-05-19T16:41:42Z")

</div>

I’d read thru [OAuth 2.0 for Web Based Applications | esi-docs](https://docs.esi.evetech.net/docs/sso/web_based_sso_flow.html) and [Refreshing tokens | esi-docs](https://docs.esi.evetech.net/docs/sso/refreshing_access_tokens.html#web-based-applications).

Few things I noticed:

1. You’re making requests against the v1 oauth routes, when it should be like `/v2/oauth/authorize` and `/v2/oauth/token`.
2. Your `access_token` != `refresh_token`. You should have gotten both back in your step 2 here.

---

<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:** [August 17, 2021, 4:42pm UTC](https://forums.eveonline.com/t/esi-the-refresh-token-is-malformed/312434/3 "2021-08-17T16:42:26Z")

</div>

Closed on August 17, 2021, 4:42pm UTC

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