當前位置: 首頁>>代碼示例>>Golang>>正文


Golang common.Provider類代碼示例

本文整理匯總了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;未經允許,請勿轉載。