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

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

  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 ?

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.

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

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
}

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

    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)
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

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.

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

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

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