# ESI SSO POST request error JS

**URL:** <https://forums.eveonline.com/t/esi-sso-post-request-error-js/320648>\
**Category:** Third Party Developers\
**Created:** [July 20, 2021, 6:36pm UTC](https://forums.eveonline.com/t/esi-sso-post-request-error-js/320648 "2021-07-20T18:36:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Le\_Fist](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/le_fist/32/372288_2.png) [@Le\_Fist](https://forums.eveonline.com/u/Le_Fist)\
**Post date:** [July 20, 2021, 6:36pm UTC](https://forums.eveonline.com/t/esi-sso-post-request-error-js/320648/1 "2021-07-20T18:36:37Z")

</div>

Hi there,  
I think I’m to dumb to see the error here. I’m at point 5 of [OAuth 2.0 for Web Based Applications | esi-docs](https://docs.esi.evetech.net/docs/sso/web_based_sso_flow.html)  
and need to make a POST request, but I always receive the following error:

error: ‘invalid\_grant’,  
error\_description: ‘Grant type is not supported.’

although the documentation clearly tells me to set it to “authorization\_code”.

The query.code is provided by calling `https://login.eveonline.com/v2/oauth/authorize/`, so it is a v2 code.

Maybe someone of you can see what I’m doing wrong here.

Thank you very much.

I replaced all credentials of the application with ||||||||||| to censor them, but in my code, they are working (I changed them and got back other errors)

```auto
const app = express();
const port = process.env.PORT || 8000;

app.use(express.json());
app.use(cors({
    origin: "*"
}));

app.get("/", async(req, res, next) => {
    const query = req.query;
    const auth = "|||||||||||||||||||||| : |||||||||||||||||||||||||||"
    console.log(query)
    const header = {
        "Authorization": "Basic |||||||||||||||||||||||",
        "Content-Type": "application/x-www-form-urlencoded",
        "Host": "login.eveonline.com"
    }

    try{
        const {data} = await axios.post(`https://login.eveonline.com/v2/oauth/token`,
        {
            grant_type: "authorization_code"
        }, 
        {
            headers: header
        }
        )
        console.log(data);
    }catch(err){
        //console.log(err)
    }

    next()
})

const wss = new WebSocket.Server({ port: 8080 },()=>{
    console.log('websocket server running')
})

wss.on('connection', function connection(ws) {
    const id = uuid();
    ws.id = id
    ws.send(`id;${id}`)
    //ws.on('message', (data) => {
    // ws.send(`id;${id}`)
    //})
 })

 app.listen(port, () => {
     console.log("express server running")
 })

```

---

<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:** [July 20, 2021, 6:53pm UTC](https://forums.eveonline.com/t/esi-sso-post-request-error-js/320648/2 "2021-07-20T18:53:48Z")

</div>

Two things things to double check:

1. You need to make the POST with form encoded data as the body, not JSON
2. You also need to include the code within the body, which it doesn’t look like you are

Another thing you can try is make the request via Postman or curl to validate things are working. Then you would know it’s a code issue.

---

<div class="post-metadata">

**Author:** ![Le\_Fist](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/le_fist/32/372288_2.png) [@Le\_Fist](https://forums.eveonline.com/u/Le_Fist)\
**Post date:** [July 20, 2021, 6:57pm UTC](https://forums.eveonline.com/t/esi-sso-post-request-error-js/320648/3 "2021-07-20T18:57:21Z")

</div>

I did made them via Postman and got the same error. I can try points 1 and 2. Thanks for your answer.

---

<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:** [October 18, 2021, 6:57pm UTC](https://forums.eveonline.com/t/esi-sso-post-request-error-js/320648/4 "2021-10-18T18:57:42Z")

</div>

Closed on October 18, 2021, 6:57pm UTC

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