I created a spreadsheet using Google Sheets API with service account however I can't reach it when I try to reach with url I get an access error. I also tried set permissions.create but I couldn't figured out how can I find file(when I use id of spreadsheet which is in url, I take file not found error on Google Drive API) id that contain this spreadsheet. Is there any way to make spreadsheets public (maybe when creating)?
Here is my createspreadsheet function
func createSpreadsheet(ctx context.Context, title string, creds []byte) (*GoogleSpreadsheet, error) {
srv, err := sheets.NewService(ctx, option.WithCredentialsJSON(creds))
if err != nil {
return nil, err
}
var (
prop = &sheets.SpreadsheetProperties{
Title: title,
}
sheet = &sheets.Spreadsheet{
Properties: prop,
}
)
resp, err := srv.Spreadsheets.Create(sheet).Do() //Create request is send
if err != nil {
return nil, err
}
gs := &GoogleSpreadsheet{
SpreadSheetID: resp.SpreadsheetId,
SpreadSheetName: title,
SheetID: resp.Sheets[0].Properties.SheetId,
SheetName: resp.Sheets[0].Properties.Title,
URL: resp.SpreadsheetUrl,
Service: srv,
}
mux.Lock()
defer mux.Unlock()
spreadsheets[gs.SpreadSheetID] = gs
return gs, nil
}
however I can't reach it when I try to reach with url I get an access error
, I cannot understand about the detail situation. I apologize for this. Can I ask you about the detail of it? – Tanaikepermissions.create
, you do it with the same account that originally created the spreadsheet? – IamblichusI found spreadsheet url which is created by service account from my code and I tried to reach to spreadsheet with this url (docs.google.com/spreadsheets/d/xxxxxxxxxxxxxxx/edit) and I get an error that says you need to access.
, in this case, how do you want to access to the Spreadsheet? – Tanaike