Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A graceful golang sdk for Lark/Feishu

License

NotificationsYou must be signed in to change notification settings

joyqi/go-lafi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lafi = lark + feishu

go-lafi is a Go client library for accessing the Lark/Feishu API.

As of now I am writing this library, there is no official Lark/Feishu SDK for Go.Although Bytedance is the fastest growing tech company in China,seems like they don't want to hire a Go developer to write a Go SDK for Lark/Feishu. 😂

The goals of this library are:

  1. Provide a complete and idiomatic Go client for the Feishu API.
  2. Ensure that the library is well tested and documented.
  3. Practice my Go skills.🤖️

Installation

go get github.com/joyqi/go-lafi

Usage

OAuth2 Authentication

Initialize Lark client with OAuth2 authentication:

import"github.com/joyqi/go-lafi/oauth2"varconf=&oauth2.Config{AppID:"your-client-id",AppSecret:"your-client-secret",RedirectURL:"your-redirect-url",}

For Feishu, you can specify theType field toTypeFeishu:

import"github.com/joyqi/go-lafi/oauth2"varconf=&oauth2.Config{AppID:"your-client-id",AppSecret:"your-client-secret",RedirectURL:"your-redirect-url",Type:oauth2.TypeFeishu,}

Get the authorization URL:

url:=conf.AuthCodeURL("your-state")

Exchange the authorization code for an access token:

token,err:=conf.Exchange(ctx,code)

Use TokenSource to persist the token and refresh it as needed:

ts:=conf.TokenSource(ctx,token)token,err:=ts.Token()

Lark/Feishu API

Features:

  • contact
    • User
    • Department
    • Group
    • Unit
    • EmployeeTypeEnums
    • CustomAttr
    • Scope

Initialize API client:

import"github.com/joyqi/go-lafi/oauth2"client:=conf.TenantTokenSource(ctx).Client()

Use the client to access the API. For example, to list all groups:

import ("github.com/joyqi/go-lafi/oauth2""github.com/joyqi/go-lafi/api/contact")client:=conf.TenantTokenSource(ctx).Client()api:=&contact.Group{Client:client}api.SimpleList(&contact.GroupSimpleListParams{PageSize:100,})

[8]ページ先頭

©2009-2025 Movatter.jp