I am working in a Golang application, this one is connected to a Oauth2 service, right now I have the refresh token and I need to get a new access token with it, I am using golang.org/x/oauth2
but it wans't successful, so there's something that I am missing, currently I have:
refresh_token := "some_refresh_token"
var conf = oauth2.Config{
ClientID:MY_CLIENT,
ClientSecret:MY_CLIENT_SECRET,
Scopes:[]string{"refresh_token"},
RedirectURL:"https://mydomain/callback",
Endpoint: oauth2.Endpoint{
AuthURL:"myoauth2Cluster.com/oauth2/auth",
TokenURL: "myoauth2Cluster.com/oauth2/token",
},
}
t := new (oauth2.Token)
t.RefreshToken=refresh_token
myclient := conf.Client(context.Background(),t)
req, err := http.NewRequest("GET",DontKnowWhichURLhere , nil)
if err != nil {
fmt.Println("error:",err.Error())
}
mrr, er := myclient.Do(req)
if(er!=nil){
fmt.Println(er.Error())
}else{
fmt.Println("status code:",mrr.StatusCode)
}
But I am getting a 404 status, I checked the logs of the Oauth2 server and there I have
msg="completed handling request" measure#https://myOauth2Cluster.latency=100648 method=GET remote=xxx.xxx.xx.xxx request="/" status=404 text_status="Not Found" took=100.648µs
Also, I am not really sure which URL should I stablish when I create the http.NewRequest
should it be a callback? or the url of the Oauth2 Server?
If there's some example of how to renew the access token using this library would be nice, but at the moment I haven't found it