The best I can come up with is the Google API client, which does not seem to support docs. I just need to grab some values from a spreadsheet (no writing). If there isn't a library, any hints on how to authenticate w/ OAuth2 in Go? Also, the following seems to result in an invalid SSL certificate:
tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
client := &http.Client{Transport: tr}
resp, err := client.Get("https://spreadsheets.google.com/feeds/cells/myid/1/private/full")
if err != nil {
panic(err)
}
r, _ := json.MarshalIndent(resp, "", " ")
log.Println(string(r)) // json telling me about an invalid certificate
**评论:**
anoland:
fsdfsdjflkdsjfsdklj:It appears that you can still get spreadsheet data as json,
If your spreadsheet is published to the web all you have to do is add
alt=json
to the url in order to use the data in JSON format. Example: https://spreadsheets.google.com/feeds/list/1HGVmKJJ_W5p-SEbzLTRM4p5v_al9XC7yyjmTlbRtGAk/od6/public/basic?hl=en_US&alt=jsonIf it isn't but you think you can get access to the non-published version using Oauth2 then there is a google Oauth2 client that you would use to get around that restriction. I've never tried what I'm suggesting, but it makes sense that you would have to do that.
This may help you get the oauth client you need. http://golangtutorials.blogspot.com/2011/11/oauth2-3-legged-authorization-in-go-web.html
anoland:Is using it without OAuth2 going to be deprecated? https://developers.google.com/gdata/samples/spreadsheet_sample
nate510:Only google knows.
fsdfsdjflkdsjfsdklj:
nate510:For the OAuth2 part, is that what you mean?
EDIT: I didn't see a way to read a spreadsheet.
tealeg:Ah, yeah, I guess those APIs are for manipulating files and not for parsing them. Looks like only Java and .NET clients are maintained by Google.
Sorry, couldn't find anything in Go to do what you're asking.
If you only want to read the content of the spreadsheet, then you could download it in XLSX format and use xlsx to read it.
