# ESI SSO POST error Invalid Grant

**URL:** <https://forums.eveonline.com/t/esi-sso-post-error-invalid-grant/342333>\
**Category:** Third Party Developers\
**Tags:** esi\
**Created:** [December 19, 2021, 2:41am UTC](https://forums.eveonline.com/t/esi-sso-post-error-invalid-grant/342333 "2021-12-19T02:41:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kurtisthe1st](https://imageserver.eveonline.com/Character/1_512.jpg) [@Kurtisthe1st](https://forums.eveonline.com/u/Kurtisthe1st)\
**Post date:** [December 19, 2021, 2:41am UTC](https://forums.eveonline.com/t/esi-sso-post-error-invalid-grant/342333/1 "2021-12-19T02:41:47Z")

</div>

When attempting to authenticate following the steps listed in [Web\_based\_sso\_flow](https://docs.esi.evetech.net/docs/sso/web_based_sso_flow.html) I receive  
error: “invalid grant”  
error\_description: “Grant type authorization\_code is not supported.”

The applicable code in my JS (React) application is

```auto
const authID = encode(props.secrets.client_id+":"+props.secrets.secret_key);
    
    const bodyValues = {
        'grant_type': 'authorization_code',
        'code': code
    }
    
    const formBody = Object.keys(bodyValues).map(key => encodeURIComponent(key) + '=' + encodeURIComponent(bodyValues[key])).join('&');
    
    const requestOptions = {
        method: 'POST',
        headers: {'Authorization': 'Basic ' + authID,
            'Content-Type': 'application/x-www-form-urlencoded',
            'Host': 'login.eveonline.com'},
        body: formBody
    }
    
    console.log("Sending authorization request", requestOptions);
    fetch('https://login.eveonline.com/v2/oauth/token', requestOptions)

```

I am stumped as to how I am formatting this request incorrectly as the documentation clearly states that authorization\_code is the correct grant type.

An example of the body edited to remove the actual code

```auto
grant_type=authorization_code&code=<code>

```

I am aware that i need to switch over to [native\_sso\_flow](https://docs.esi.evetech.net/docs/sso/native_sso_flow.html) but wanted to get a working post request first.

Edit: I receive the error description "“Grant type is not supported.” with postman

---

<div class="post-metadata">

**Author:** ![Steve\_Ronuken](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/steve_ronuken/32/373894_2.png) [@Steve\_Ronuken](https://forums.eveonline.com/u/Steve_Ronuken)\
**Post date:** [December 19, 2021, 2:58pm UTC](https://forums.eveonline.com/t/esi-sso-post-error-invalid-grant/342333/2 "2021-12-19T14:58:53Z")

</div>

The web based flow does not work with V2.

---

<div class="post-metadata">

**Author:** ![Dimonian](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/dimonian/32/306337_2.png) [@Dimonian](https://forums.eveonline.com/u/Dimonian)\
**Post date:** [January 28, 2022, 3:18pm UTC](https://forums.eveonline.com/t/esi-sso-post-error-invalid-grant/342333/3 "2022-01-28T15:18:24Z")

</div>

Face the same issue. How to fix it? What does it mean V2 is not supported web? How then the users can log in from a website?

---

<div class="post-metadata">

**Author:** ![Dimonian](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/dimonian/32/306337_2.png) [@Dimonian](https://forums.eveonline.com/u/Dimonian)\
**Post date:** [January 31, 2022, 12:55pm UTC](https://forums.eveonline.com/t/esi-sso-post-error-invalid-grant/342333/4 "2022-01-31T12:55:32Z")

</div>

I found a way how to solve this. For some reason it’s start to work if add `client_Id`, and `scope` inside request body (`const bodyValues =` ). Also `'Authorization': 'Basic ' + authID`, sould be removed form header because system will read credential from request body.

---

<div class="post-metadata">

**Author:** ![Laguna\_Elon\_Rothschild](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/laguna_elon_rothschild/32/306841_2.png) [@Laguna\_Elon\_Rothschild](https://forums.eveonline.com/u/Laguna_Elon_Rothschild)\
**Post date:** [February 2, 2022, 3:41am UTC](https://forums.eveonline.com/t/esi-sso-post-error-invalid-grant/342333/5 "2022-02-02T03:41:12Z")

</div>

This did not work for me, and I’m getting the same error.

---

<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, 2022, 3:41am UTC](https://forums.eveonline.com/t/esi-sso-post-error-invalid-grant/342333/6 "2022-05-03T03:41:32Z")

</div>

Closed on May 3, 2022, 3:41am UTC

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