当前仓库属于暂停状态,部分功能使用受限,详情请查阅 仓库状态说明
2 Star 0 Fork 1

JUMEI_ARCH / go-plugins
暂停

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
options.go 679 Bytes
一键复制 编辑 原始数据 按行查看 历史
Asim Aslam 提交于 2018-03-03 12:28 . switch to stdlib context
package eureka
import (
"context"
"net/http"
"github.com/micro/go-micro/registry"
"golang.org/x/oauth2"
"golang.org/x/oauth2/clientcredentials"
)
type contextHttpClient struct{}
var newOAuthClient = func(c clientcredentials.Config) *http.Client {
return c.Client(oauth2.NoContext)
}
// Enable OAuth 2.0 Client Credentials Grant Flow
func OAuth2ClientCredentials(clientID, clientSecret, tokenURL string) registry.Option {
return func(o *registry.Options) {
c := clientcredentials.Config{
ClientID: clientID,
ClientSecret: clientSecret,
TokenURL: tokenURL,
}
o.Context = context.WithValue(o.Context, contextHttpClient{}, newOAuthClient(c))
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/JMArch/go-plugins.git
git@gitee.com:JMArch/go-plugins.git
JMArch
go-plugins
go-plugins
v0.9.3

搜索帮助

344bd9b3 5694891 D2dac590 5694891