I'm trying to implement oauth-workflow for GitHub in golang and using https://github.com/franela/goreq to perform http(s) requests.
There is a section in which GitHub returns a code and you have to make a POST request to https://github.com/login/oauth/access_token with code, client_id and client_secret.
package main
import "fmt"
import "github.com/franela/goreq"
type param struct {
code string
client_id string
client_secret string
}
func main() {
params := param {code: "XX", client_id:"XX", client_secret: "XX"}
req := goreq.Request{
Method : "POST",
Uri : "https://github.com/login/oauth/access_token",
Body : params,
}
req.AddHeader("Content-Type", "application/json")
req.AddHeader("Accept", "application/json")
res, _ := req.Do()
fmt.Println(res.Body.ToString())
}
It is giving 404 with {"error":"Not Found"} message always.
While using Python, I'm getting the correct results with the same input data.