feat: complete auth

This commit is contained in:
Rogee
2024-11-27 20:58:41 +08:00
parent e4b9cc5f26
commit 301879ca39
10 changed files with 380 additions and 54 deletions

View File

@@ -1,6 +1,10 @@
package wechat
import "github.com/imroc/req/v3"
import (
"net/url"
"github.com/imroc/req/v3"
)
type Options func(*Client)
@@ -37,3 +41,29 @@ func WithClient(client *req.Client) Options {
we.client = client
}
}
type ScopeAuthorizeURLOptions func(url.Values)
func ScopeAuthorizeURLWithScope(scope AuthScope) ScopeAuthorizeURLOptions {
return func(v url.Values) {
v.Set("scope", scope.String())
}
}
func ScopeAuthorizeURLWithRedirectURI(uri string) ScopeAuthorizeURLOptions {
return func(v url.Values) {
v.Set("redirect_uri", uri)
}
}
func ScopeAuthorizeURLWithState(state string) ScopeAuthorizeURLOptions {
return func(v url.Values) {
v.Set("state", state)
}
}
func ScopeAuthorizeURLWithForcePopup() ScopeAuthorizeURLOptions {
return func(v url.Values) {
v.Set("forcePopup", "true")
}
}