feat: add token to the page for Chrome extension (#2804)

* feat: add token to the page for Chrome extension

* Update token_oauth.go

---------

Co-authored-by: Eric Luo <hsluoyz@qq.com>
This commit is contained in:
SamYSF
2024-03-17 22:01:28 +08:00
committed by GitHub
parent 6037f37b87
commit c8aa35c9c6
6 changed files with 59 additions and 0 deletions

View File

@ -726,3 +726,19 @@ func GetWechatMiniProgramToken(application *Application, code string, host strin
}
return token, nil, nil
}
func GetTokenForExtension(user *User, host string) (*Token, error) {
application, err := GetApplicationByUser(user)
if err != nil {
return nil, err
}
if application == nil {
return nil, fmt.Errorf("the application for user %s is not found", user.Id)
}
token, err := GetTokenByUser(application, user, "profile", "", host)
if err != nil {
return nil, err
}
return token, nil
}