ZGavin
(ZGavin)
June 21, 2021, 3:01pm
1
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
I want to know how to solve it ?
im sure that headers , Authorization , and code is correct;
Why the demo in the official document used ’ json ’ , but document said use Content-Type: application/x-www-form-urlencoded
?
ZGavin:
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.
Where do you see it using JSON
? Got a link?
ZGavin
(ZGavin)
June 21, 2021, 3:57pm
3
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
""" Python 3 Web Application OAuth 2.0 example.
This example can be run from the command line and will show you how the
OAuth 2.0 flow should be handled if you are a web based application.
Prerequisites:
* Create an SSO application at developers.eveonline.com with the scope
"esi-characters.read_blueprints.v1" and the callback URL
"https://localhost/callback/". Note: never use localhost as a callback
in released applications.
* Have a Python 3 environment available to you (possibly by using a
virtual environment: https://virtualenv.pypa.io/en/stable/).
* Run pip install -r requirements.txt with this directory as your root.
To run this example, make sure you have completed the prerequisites and then
run the following command from this directory as the root:
>>> python esi_oauth_web.py
then follow the prompts.
This file has been truncated. show original
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)
ZGavin
(ZGavin)
June 21, 2021, 4:12pm
4
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
ZGavin:
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:
That’s not JSON
. That’s a Python dict.
ZGavin
(ZGavin)
June 21, 2021, 5:20pm
6
yes, the code not from the non v2
endpoint,thank you very much!
system1
(system)
Closed
September 19, 2021, 5:21pm
7
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.