# ESI - OAuth 2.0 for Web Error( {"Message":"An error has occurred."} )

**URL:** <https://forums.eveonline.com/t/esi-oauth-2-0-for-web-error-message-an-error-has-occurred/317135>\
**Category:** Third Party Developers\
**Created:** [June 21, 2021, 3:01pm UTC](https://forums.eveonline.com/t/esi-oauth-2-0-for-web-error-message-an-error-has-occurred/317135 "2021-06-21T15:01:24Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ZGavin](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/zgavin/32/278162_2.png) [@ZGavin](https://forums.eveonline.com/u/ZGavin)\
**Post date:** [June 21, 2021, 3:01pm UTC](https://forums.eveonline.com/t/esi-oauth-2-0-for-web-error-message-an-error-has-occurred/317135/1 "2021-06-21T15:01:24Z")

</div>

At step 5, i get a res is {“Message”:“An error has occurred.”} after i send a post to [https://login.eveonline.com/v2/oauth/token](https://login.eveonline.com/v2/oauth/token)

1. I want to know how to solve it ?

im sure that headers , Authorization , and code is correct;

1. Why the demo in the official document used ’ json ’ , but document said use `Content-Type: application/x-www-form-urlencoded` ?

---

<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:** [June 21, 2021, 3:51pm UTC](https://forums.eveonline.com/t/esi-oauth-2-0-for-web-error-message-an-error-has-occurred/317135/2 "2021-06-21T15:51:18Z")

</div>

> [@ZGavin](#):
>
> 1. I want to know how to solve it ?

You’re going to need to provide more information/code in order to figure this out. That message isn’t enough to go off of.

> [@ZGavin](#):
>
> Why the demo in the official document used ’ json ’

Where do you see it using `JSON`? Got a link?

---

<div class="post-metadata">

**Author:** ![ZGavin](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/zgavin/32/278162_2.png) [@ZGavin](https://forums.eveonline.com/u/ZGavin)\
**Post date:** [June 21, 2021, 3:57pm UTC](https://forums.eveonline.com/t/esi-oauth-2-0-for-web-error-message-an-error-has-occurred/317135/3 "2021-06-21T15:57:15Z")

</div>

> [@Blacksmoke16](#):
>
> You’re going to need to provide more information/code in order to figure this out. That message isn’t enough to go off of.

```auto
func getESIToken(code string) (content string) {
	o := "grant_type=authorization_code&code=" + code
	fmt.Println(o)
	req, err := http.NewRequest("POST", "https://login.eveonline.com/v2/oauth/token", strings.NewReader(o))
	req.Header.Add("Authorization", "Basic YjgzMTg0ZGUzNWQ4NGYxODk4ZmZlZjM0MDczNjUwZjE6Q2ZLQWY0VnQ5MUt4eVFIM2c5a21sZkx3MWxRQ3FQVEZaRU9peVl2VA==")
	req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
	if err != nil {
		panic(err)
	}
	defer req.Body.Close()
	client := &http.Client{Timeout: 15 * time.Second}
	resp, error := client.Do(req)
	if error != nil {
		panic(error)
	}
	defer resp.Body.Close()
	result, _ := ioutil.ReadAll(resp.Body)
	content = string(result)
	return
}

```

```auto
2021/06/21 23:52:06.908 [I] [parser.go:413] generate router from comments

2021/06/21 23:52:06.908 [I] [server.go:241] http server Running on http://:8088

code: vaV37JTTrCi3Zun-aSYSj0btj4MWOKD6iwuotfb10ymNrhaTHu1jRnGu7ZKmx4xc
grant_type=authorization_code&code=vaV37JTTrCi3Zun-aSYSj0btj4MWOKD6iwuotfb10ymNrhaTHu1jRnGu7ZKmx4xc
{"Message":"An error has occurred."}
2021/06/21 23:52:15.930 [D] [router.go:955] | ::1| 301 | 4.2383098s| match| GET /api/callback/ r:/api/callback

```

> [@Blacksmoke16](#):
>
> Where do you see it using `JSON`? Got a link?

> <https://github.com/esi/esi-docs/blob/master/examples/python/sso/esi_oauth_web.py>

```auto
    form_values = {
        "grant_type": "authorization_code",
        "code": auth_code,
    }

    auth_header = "Basic {}".format(basic_auth)

    headers = {"Authorization": auth_header}

    res = send_token_request(form_values, add_headers=headers)

```

---

<div class="post-metadata">

**Author:** ![ZGavin](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/zgavin/32/278162_2.png) [@ZGavin](https://forums.eveonline.com/u/ZGavin)\
**Post date:** [June 21, 2021, 4:12pm UTC](https://forums.eveonline.com/t/esi-oauth-2-0-for-web-error-message-an-error-has-occurred/317135/4 "2021-06-21T16:12:31Z")

</div>

```auto
2021/06/22 00:11:28.796 [I] [parser.go:413] generate router from comments

2021/06/22 00:11:28.797 [I] [server.go:241] http server Running on http://:8088

code: Llh7O4-82uWFd7IRNc5mxlv7DPQjAWrnEx4nJEcbwjZvtK7gcSqHALhHTtW77KHF
post url: https://login.eveonline.com/v2/oauth/token
post params: grant_type=authorization_code&code=Llh7O4-82uWFd7IRNc5mxlv7DPQjAWrnEx4nJEcbwjZvtK7gcSqHALhHTtW77KHF
Authorization: Basic YjgzMTg0ZGUzNWQ4NGYxODk4ZmZlZjM0MDczNjUwZjE6Q2ZLQWY0VnQ5MUt4eVFIM2c5a21sZkx3MWxRQ3FQVEZaRU9peVl2VA==
Content-Type: application/x-www-form-urlencoded
{"Message":"An error has occurred."}
2021/06/22 00:11:40.075 [D] [router.go:955] | ::1| 301 | 2.0410832s| match| GET /api/callback/ r:/api/callback

```

---

<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:** [June 21, 2021, 5:09pm UTC](https://forums.eveonline.com/t/esi-oauth-2-0-for-web-error-message-an-error-has-occurred/317135/5 "2021-06-21T17:09:06Z")

</div>

> [@ZGavin](#):
>
> > [@Blacksmoke16](#):
> >
> > You’re going to need to provide more information/code in order to figure this out. That message isn’t enough to go off of.

Are you getting the code from the right endpoint? `https://login.eveonline.com/v2/oauth/authorize/`? I did some testing and apparently this is the error that’s returned when the `code` is invalid. So either you’re getting the code from the non `v2` endpoint, or something with the `Go` code isn’t entirely correct. If you are using the `v2` endpoint, try making the request via `Postman` or `curl` to see if that works; if so then you know something is up with the code.

Also, I’d be sure to cycle your OAuth app secret key given it’s just been exposed publicly.

> [@ZGavin](#):
>
> > [@Blacksmoke16](#):
> >
> > Where do you see it using `JSON`? Got a link?

That’s not `JSON`. That’s a Python dict.

---

<div class="post-metadata">

**Author:** ![ZGavin](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/zgavin/32/278162_2.png) [@ZGavin](https://forums.eveonline.com/u/ZGavin)\
**Post date:** [June 21, 2021, 5:20pm UTC](https://forums.eveonline.com/t/esi-oauth-2-0-for-web-error-message-an-error-has-occurred/317135/6 "2021-06-21T17:20:58Z")

</div>

yes, the code not from the non `v2` endpoint,thank you very much!

---

<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:** [September 19, 2021, 5:21pm UTC](https://forums.eveonline.com/t/esi-oauth-2-0-for-web-error-message-an-error-has-occurred/317135/7 "2021-09-19T17:21:07Z")

</div>

Closed on September 19, 2021, 5:21pm UTC

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