You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
638 B
24 lines
638 B
package tools
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/openimsdk/protocol/auth"
|
|
"github.com/openimsdk/tools/log"
|
|
)
|
|
|
|
// fetchChatAdminToken 通过 IM auth-rpc GetAdminToken 获取管理员 token。
|
|
// 使用 config.Share.Secret 和第一个 IMAdminUserID 作为凭据。
|
|
func (c *cronServer) fetchChatAdminToken(ctx context.Context) (string, error) {
|
|
userID := c.config.Share.IMAdminUserID[0]
|
|
resp, err := c.authClient.GetAdminToken(ctx, &auth.GetAdminTokenReq{
|
|
Secret: c.config.Share.Secret,
|
|
UserID: userID,
|
|
})
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
log.ZDebug(ctx, "fetchChatAdminToken: ok", "userID", userID)
|
|
return resp.Token, nil
|
|
}
|