本文整理汇总了Golang中github.com/outrightmental/go-omniauth/common.Provider类的典型用法代码示例。如果您正苦于以下问题:Golang Provider类的具体用法?Golang Provider怎么用?Golang Provider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Provider类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: NewUser
// NewUser builds a new User object for Heroku.
func NewUser(data objx.Map, creds *common.Credentials, provider common.Provider) *User {
user := &User{data}
creds.Set(common.CredentialsKeyID, data[herokuKeyID])
// set provider credentials
user.data[common.UserKeyProviderCredentials] = map[string]*common.Credentials{
provider.Name(): creds,
}
return user
}
开发者ID:outrightmental,项目名称:go-omniauth,代码行数:12,代码来源:user.go
示例2: Get
// Get executes an authenticated HTTP GET against the given provider and returns an
// objx.Map of the response.
//
// The response type is automatically detected and used to unmarshal the response.
func Get(provider common.Provider, creds *common.Credentials, endpoint string) (objx.Map, error) {
client, clientErr := provider.GetClient(creds)
if clientErr != nil {
return nil, clientErr
}
response, responseErr := client.Get(endpoint)
if responseErr != nil {
return nil, responseErr
}
body, bodyErr := ioutil.ReadAll(response.Body)
if bodyErr != nil {
return nil, bodyErr
}
defer response.Body.Close()
codecs := services.NewWebCodecService()
codec, getCodecErr := codecs.GetCodec(response.Header.Get("Content-Type"))
if getCodecErr != nil {
return nil, getCodecErr
}
var data objx.Map
unmarshalErr := codec.Unmarshal(body, &data)
if unmarshalErr != nil {
return nil, unmarshalErr
}
return data, nil
}
开发者ID:outrightmental,项目名称:go-omniauth,代码行数:43,代码来源:get.go
示例3: ProviderPublicData
// ProviderPublicData gets the public data for the specified provider.
//
// The options should contain the `loginpathFormat`, which will determine how the
// loginpath value is created.
func ProviderPublicData(provider common.Provider, options map[string]interface{}) (interface{}, error) {
optionsx := objx.New(options)
return map[string]interface{}{
"name": provider.Name(),
"display": provider.DisplayName(),
"loginpath": fmt.Sprintf(optionsx.Get("loginpathFormat").Str("auth/%s/login"), provider.Name()),
}, nil
}
开发者ID:outrightmental,项目名称:go-omniauth,代码行数:15,代码来源:facade.go
注:本文中的github.com/outrightmental/go-omniauth/common.Provider类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论