### Install Qidian SDK Go Source: https://github.com/tencentqidian/qidian-sdk-go/blob/master/README.md Install the Qidian SDK for Go using the go get command. ```shell go get github.com/tencentqidian/qidian-sdk-go ``` -------------------------------- ### Get Department List Source: https://github.com/tencentqidian/qidian-sdk-go/blob/master/README.md Fetch a list of all departments within the corporation. This operation requires an authenticated client. ```go // 获取部门列表 depts, err := client.Departments(context.Background()) ``` -------------------------------- ### Get Corporate Information Source: https://github.com/tencentqidian/qidian-sdk-go/blob/master/README.md Retrieve information about the corporation using the initialized client. This API call requires a valid access token. ```go // 获取企业信息 corpInfo, err := client.GetCorpInfo(context.Background()) ``` -------------------------------- ### Get Component Token Source: https://github.com/tencentqidian/qidian-sdk-go/blob/master/README.md Obtain a component access token using the component verify ticket. This token is required for certain administrative operations. ```go // 获取应用开发商 token resp, err := cmpt.GetComponentToken(context.Background(), &types.GetComponentTokenReq{ ComponentVerifyTicket: "COMPONENT_VERIFY_TICKET", }) ``` -------------------------------- ### Initialize Qidian Component Client Source: https://github.com/tencentqidian/qidian-sdk-go/blob/master/README.md Create a new Qidian component client with your application's credentials. This client is used for obtaining tokens and interacting with the Qidian API. ```go import ( sdk "github.com/tencentqidian/qidian-sdk-go" ) func main() { // 创建服务商对象 cmpt := sdk.NewComponent( sdk.WithComponentAppID("APP_ID"), sdk.WithComponentAppSecret("APP_SECRET"), ) ``` -------------------------------- ### Initialize Qidian Client with Access Token Source: https://github.com/tencentqidian/qidian-sdk-go/blob/master/README.md Create a Qidian client using a pre-obtained access token. This client is used for making direct API calls on behalf of an authorized application. ```go // 通过 ACCESS_TOKEN 调用服务端 API client := sdk.NewClient( sdk.WithAccessToken("ACCESS_TOKEN"), ) ``` -------------------------------- ### Exchange Authorization Code for OAuth APP Token Source: https://github.com/tencentqidian/qidian-sdk-go/blob/master/README.md Use an authorization code to exchange for an application authorization token. This is typically done after a user grants authorization to your application. ```go // 使用应用授权code换取应用授权token resp, err := cmpt.GetOAuthAPPToken(context.Background(), &types.GetOAuthAPPTokenReq{ AuthorizationCode: "AUTHORIZATION_CODE", }) ``` -------------------------------- ### Refresh Authorizer Token Source: https://github.com/tencentqidian/qidian-sdk-go/blob/master/README.md Refresh an authorizer's access token using their refresh token. This is necessary when the current access token expires. ```go // 刷新 Token refreshResp, err := cmpt.RefreshAuthorizerToken(context.Background(), &types.RefreshAuthorizerTokenReq{ AuthorizerAppID: "AUTHORIZER_APP_ID", AuthorizerRefreshToken: "AUTHORIZER_REFRESH_TOKEN", SID: "APPLICATION_ID", }) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.