Skip to content
Snippets Groups Projects
Commit a2c35b39 authored by Yoan VALLET's avatar Yoan VALLET
Browse files

Update redirect auth point to enedis

parent fc48964d
No related branches found
No related tags found
No related merge requests found
Pipeline #5581 passed
......@@ -45,26 +45,10 @@ func main() {
redirectUri := "https://oauth-proxy.wf.alpha.grandlyon.com/redirect"
responseType := "code"
authReq := "https://mon-compte-particulier.enedis.fr/dataconnect/v1/oauth2/authorize?client_id="+ clientId +"&duration=P6M&redirect_uri="+ redirectUri +"&response_type="+ responseType +"&state="+ state +"-"+ cozyOrigin
redirectUrl := "https://mon-compte-particulier.enedis.fr/dataconnect/v1/oauth2/authorize?client_id="+ clientId +"&duration=P6M&redirect_uri="+ redirectUri +"&response_type="+ responseType +"&state="+ state +"-"+ cozyOrigin
fmt.Println(time.Now().Format("2006-01-02 15:04:05"), "- Send request to auth endpoint", authReq)
response, err := http.Get(authReq)
fmt.Println(time.Now().Format("2006-01-02 15:04:05"), "- Endpoint response with status", response.Status)
if err != nil {
fmt.Println(err)
} else {
defer response.Body.Close()
contents, err := ioutil.ReadAll(response.Body)
if err != nil {
fmt.Println(err)
}
if response.StatusCode >= 200 && response.StatusCode <= 299 {
w.Write(contents)
} else {
http.Error(w, http.StatusText(response.StatusCode), response.StatusCode)
}
}
fmt.Println(time.Now().Format("2006-01-02 15:04:05"), "- Redirect to - ", redirectUrl)
http.Redirect(w, r, redirectUrl, 302)
})
mux.HandleFunc("/redirect", func(w http.ResponseWriter, r *http.Request) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment