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


Golang goth.Params類代碼示例

本文整理匯總了Golang中github.com/markbates/goth.Params的典型用法代碼示例。如果您正苦於以下問題:Golang Params類的具體用法?Golang Params怎麽用?Golang Params使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Params類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Authorize

// Authorize the session with Dropbox and return the access token to be stored for future use.
func (s *Session) Authorize(provider goth.Provider, params goth.Params) (string, error) {
	p := provider.(*Provider)
	token, err := p.config.Exchange(oauth2.NoContext, params.Get("code"))
	if err != nil {
		return "", err
	}
	s.Token = token.AccessToken
	return token.AccessToken, nil
}
開發者ID:drathier,項目名稱:goth,代碼行數:10,代碼來源:dropbox.go

示例2: Authorize

// Authorize the session with Twitter and return the access token to be stored for future use.
func (s *Session) Authorize(provider goth.Provider, params goth.Params) (string, error) {
	p := provider.(*Provider)
	accessToken, err := p.consumer.AuthorizeToken(s.RequestToken, params.Get("oauth_verifier"))
	if err != nil {
		return "", err
	}
	s.AccessToken = accessToken
	return accessToken.Token, err
}
開發者ID:bryanl,項目名稱:doit-server,代碼行數:10,代碼來源:session.go

示例3: Authorize

// Authorize the session with LastFM and return the access token to be stored for future use.
func (s *Session) Authorize(provider goth.Provider, params goth.Params) (string, error) {
	p := provider.(*Provider)
	sess, err := p.GetSession(params.Get("token"))
	if err != nil {
		return "", err
	}
	s.AccessToken = sess["token"]
	s.Login = sess["login"]
	return sess["token"], err
}
開發者ID:drathier,項目名稱:goth,代碼行數:11,代碼來源:session.go

示例4: Authorize

// Authorize the session with Dropbox and return the access token to be stored for future use.
func (s *Session) Authorize(provider goth.Provider, params goth.Params) (string, error) {
	p := provider.(*Provider)
	token, err := p.config.Exchange(oauth2.NoContext, params.Get("code"))
	if err != nil {
		return "", err
	}

	if !token.Valid() {
		return "", errors.New("Invalid token received from provider")
	}

	s.Token = token.AccessToken
	return token.AccessToken, nil
}
開發者ID:rossnanop,項目名稱:goth,代碼行數:15,代碼來源:dropbox.go

示例5: Authorize

// Authorize the session with Cloud Foundry and return the access token to be stored for future use.
func (s *Session) Authorize(provider goth.Provider, params goth.Params) (string, error) {
	p := provider.(*Provider)
	ctx := context.WithValue(oauth2.NoContext, oauth2.HTTPClient, p.Client)
	token, err := p.config.Exchange(ctx, params.Get("code"))
	if err != nil {
		return "", err
	}

	if !token.Valid() {
		return "", errors.New("Invalid token received from provider")
	}

	s.AccessToken = token.AccessToken
	s.RefreshToken = token.RefreshToken
	s.ExpiresAt = token.Expiry
	return token.AccessToken, err
}
開發者ID:bentranter,項目名稱:goth,代碼行數:18,代碼來源:session.go

示例6: Authorize

// Authorize the session with Stripe and return the access token to be stored for future use.
func (s *Session) Authorize(provider goth.Provider, params goth.Params) (string, error) {
	p := provider.(*Provider)
	token, err := p.config.Exchange(oauth2.NoContext, params.Get("code"))
	if err != nil {
		return "", err
	}

	if !token.Valid() {
		return "", errors.New("Invalid token received from provider")
	}

	s.AccessToken = token.AccessToken
	s.RefreshToken = token.RefreshToken
	s.ExpiresAt = token.Expiry
	s.ID = token.Extra("stripe_user_id").(string) //Required to get the user info from sales force
	return token.AccessToken, err
}
開發者ID:rossnanop,項目名稱:goth,代碼行數:18,代碼來源:session.go


注:本文中的github.com/markbates/goth.Params類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。