larksuite / oapi-sdk-go

larksuite oapi sdk by golang
MIT License
430 stars 87 forks source link

飞书表格修改sheet title 失败 #133

Open gllxdxw075 opened 6 months ago

gllxdxw075 commented 6 months ago
package test

import (
        "context"
        "fmt"
        "net/http"
        "testing"

        lark "github.com/larksuite/oapi-sdk-go/v3"
        larkcore "github.com/larksuite/oapi-sdk-go/v3/core"
        larksheets "github.com/larksuite/oapi-sdk-go/v3/service/sheets/v3"
)

func TestFeshu(t *testing.T) {
        header := http.Header{}
        header.Add("Authorization", "my user token")
        cli := lark.NewClient(
                "id", "sec",
                lark.WithHeaders(header))
        resp, err := cli.Sheets.V3.Spreadsheet.Patch(
                context.Background(),
                larksheets.NewPatchSpreadsheetReqBuilder().
                        SpreadsheetToken("sheettoken").
                        UpdateSpreadsheetProperties(
                                larksheets.
                                        NewUpdateSpreadsheetPropertiesBuilder().
                                        Title("test").Build(),
                        ).Build())
        //处理错误
        if err != nil {
                // 处理err
                return
        }

        // 服务端错误处理
        if !resp.Success() {
                fmt.Println(resp.Code, resp.Msg, resp.RequestId())
                return
        }

        // 业务数据处理
        fmt.Println(larkcore.Prettify(resp.RawBody))
}

按照上面的测试(替换对应的ID和TOKEN),会报错Access denied. One of the following scopes is required: [sheets:spreadsheet, drive:drive]

gllxdxw075 commented 6 months ago

备注: