Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

access_token 缓存 key 有计划放开自定义吗? #71

Open
wanglelecc opened this issue Jan 10, 2022 · 3 comments
Open

access_token 缓存 key 有计划放开自定义吗? #71

wanglelecc opened this issue Jan 10, 2022 · 3 comments

Comments

@wanglelecc
Copy link

系统中有调用多个小程序需求,能放开自定义,或者 key里面加上 appid

func (cli *Client) tokenCacheKey() string {
	return fmt.Sprintf("weapp.access.token.%s", cli.appid)
}
@royalrick
Copy link
Owner

这个应该可以

package main

import (
	"github.com/medivhzhan/weapp/v3"
)

func main() {
	tokenGetter := func() (token string, expireIn uint) {

		expireIn = 1000
		token = "your-custom-token"

		return token, expireIn
	}

	sdk := weapp.NewClient(
		"your-appid",
		"your-secret",
		weapp.WithAccessTokenSetter(tokenGetter),
	)
}

@royalrick
Copy link
Owner

v3.6.4 版本也已经把appid加入缓存key

@wanglelecc
Copy link
Author

好的,感谢!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants