Trying to connect to SharePoint as explained here, I was able to get the security token
and need to post it to https://yourdomain.sharepoint.com/_forms/default.aspx?wa=wsignin1.0
to get the access token
.
The response from this request includes couple of cookies which must
be passed as headers with all future requests. They are marked with
the ‘Set-Cookie’ header. We need the ones beginning with rtFa= and
FedAuth=. The access token cookies must be included as Cookie headers
with the POST request of
https://yourdomain.sharepoint.com/_api/contextinfo
With Thunder client
I was able to get these cookies.
But I failed to get them through my GO code, i tried as:
token := string(n.Content) // n.Content is obtained from XML read
const mydomain = "https://domain.sharepoint.com/_forms/default.aspx?wa=wsignin1.0"
resp2, err := http.Post(mydomain, "text/plain;charset=UTF-8", strings.NewReader(token))
if err != nil {
log.Fatal("error: ", err)
}
defer resp2.Body.Close()
body2, _ := ioutil.ReadAll(resp2.Body)
fmt.Println("response Body:", string(body2))
And got the output as:
2021/07/08 22:31:01 error: Post "https://domain.sharepoint.com/_forms/default.aspx?wa=wsignin1.0": dial tcp: lookup domain.sharepoint.com on 192.168.244.17:53: cannot unmarshal DNS message
exit status 1