fix(pikpak): refresh_token contention (#6501 close #6511)

This commit is contained in:
foxxorcat
2024-05-27 21:31:59 +08:00
committed by GitHub
parent 8e2b9c681a
commit 163af0515f
3 changed files with 30 additions and 22 deletions

15
pkg/utils/oauth2.go Normal file
View File

@ -0,0 +1,15 @@
package utils
import "golang.org/x/oauth2"
type tokenSource struct {
fn func() (*oauth2.Token, error)
}
func (t *tokenSource) Token() (*oauth2.Token, error) {
return t.fn()
}
func TokenSource(fn func() (*oauth2.Token, error)) oauth2.TokenSource {
return &tokenSource{fn}
}