# \[SOLVED\] Unknown grant\_type: 'authorization\_code'

**URL:** <https://forums.eveonline.com/t/solved-unknown-grant-type-authorization-code/104710>\
**Category:** Third Party Developers\
**Created:** [September 7, 2018, 10:56pm UTC](https://forums.eveonline.com/t/solved-unknown-grant-type-authorization-code/104710 "2018-09-07T22:56:32Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nomadicca](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/nomadicca/32/95463_2.png) [@Nomadicca](https://forums.eveonline.com/u/Nomadicca)\
**Post date:** [September 7, 2018, 10:56pm UTC](https://forums.eveonline.com/t/solved-unknown-grant-type-authorization-code/104710/1 "2018-09-07T22:56:33Z")

</div>

SOLUTION: I was using the wrong Content-Type

- I had x-www-form-urlencoded should (for this snippet) be json

I am working on a local copy of an app and am getting a 400 response code with “Unknown grant\_type”.

I have done some googling and only references to this that I found were because the grant\_type was actually wrong. This is not the case in my code. I have seen some other posts about this as well but for other auth paths that weren’t similar enough to get a resolution from.

Any help / suggestions are very much appreciated.

I am using Node.js with requests module installed. Code is below:  
(ID:SECRET string is redacted)

```
request.post({
            url: "https://login.eveonline.com/oauth/token",
            headers: {
                "Content-Type": "application/x-www-form-urlencoded",
                "Authorization": "Basic id:secret"
            },
            body: JSON.stringify({
                "grant_type": "authorization_code", //line that seems to be generating the error
                "code": code
            }),
        },
        function(e, r, b) {
            if (e) {
                console.log("An Error");
                console.log(e);
            } else {
                console.log(b);
            }
        }
    );
```

---

<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:** [September 7, 2018, 11:03pm UTC](https://forums.eveonline.com/t/solved-unknown-grant-type-authorization-code/104710/2 "2018-09-07T23:03:12Z")

</div>

Are you base64 encoding your `ID:SECRET` string?

If so it just sounds like the requests lib isn’t making the request correctly. Could you give a sample of what the request looks like from the browser?

---

<div class="post-metadata">

**Author:** ![Nomadicca](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/nomadicca/32/95463_2.png) [@Nomadicca](https://forums.eveonline.com/u/Nomadicca)\
**Post date:** [September 7, 2018, 11:15pm UTC](https://forums.eveonline.com/t/solved-unknown-grant-type-authorization-code/104710/3 "2018-09-07T23:15:22Z")

</div>

I used btoa to encode the string (first thing i found). Is there a better method?

The request fails with a 404 when working from a browser (since POST I think) but in Postman (Chrome App) it works fine. Postman generates the code but is using XMLHTTPRequest.

---

<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:** [September 7, 2018, 11:23pm UTC](https://forums.eveonline.com/t/solved-unknown-grant-type-authorization-code/104710/4 "2018-09-07T23:23:35Z")

</div>

If the string you got from `btoa` works in Postman then that wouldn’t be the issue i would think.

Oh.

Try changing your `Content-Type` header to `application/json`

---

<div class="post-metadata">

**Author:** ![Nomadicca](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/nomadicca/32/95463_2.png) [@Nomadicca](https://forums.eveonline.com/u/Nomadicca)\
**Post date:** [September 7, 2018, 11:25pm UTC](https://forums.eveonline.com/t/solved-unknown-grant-type-authorization-code/104710/5 "2018-09-07T23:25:55Z")

</div>

Worked a treat!

Thanks a million (because I’m spacepoor) 😃

---

<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:** [September 7, 2018, 11:26pm UTC](https://forums.eveonline.com/t/solved-unknown-grant-type-authorization-code/104710/6 "2018-09-07T23:26:07Z")

</div>

NP 🙂

---

<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:** [December 6, 2018, 11:26pm UTC](https://forums.eveonline.com/t/solved-unknown-grant-type-authorization-code/104710/7 "2018-12-06T23:26:11Z")

</div>

Closed on December 6, 2018, 11:26pm UTC

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