sample code
func main() {
fmt.Print("starting box web server...")
http.HandleFunc("/", landing)
http.HandleFunc("/handle", handler)
http.ListenAndServe(connector_port, nil)
}
func landing(w http.ResponseWriter, r *http.Request) {
fmt.Println("redirecting to login for authentication...")
http.Redirect(w, r, "http://*****urlfortoken", http.StatusFound)
}
func handler(w http.ResponseWriter, r *http.Request) {
bodyresnew_folder, _ := ioutil.ReadAll(r.Body)
fmt.Println("response Body:", string(bodyresnew_folder))
fmt.Println("1", r.GetBody)
fmt.Println("2", r.URL.String())
fmt.Println("3", r.URL.Fragment)
fmt.Println("4", r.URL.Query().Get("access_token"))
fmt.Println("inside handle function,", r.Form.Get("access_token"))
fmt.Println("finished processing all files please close this server manually")
}
I tried the code above to get fragment from an URL but was unsuccessful.
Example URL used is: http://localhost:8080/handle#access_token=*1234$111&token_type=bearer&expires_in=3600&scope=onedrive.readwrite&user_id=hashed
Now, for such URL, I want to get the value of fragment access_token
in the handler
function which is basically an http handler.
</div>