From de1f5a349e2ccabb45d6ecce699884aa8e89b110 Mon Sep 17 00:00:00 2001 From: Burcu Dogan Date: Thu, 26 Jun 2014 17:27:53 -0700 Subject: [PATCH] Dont export exchange. --- oauth2.go | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/oauth2.go b/oauth2.go index b87de7d..edfd75d 100644 --- a/oauth2.go +++ b/oauth2.go @@ -172,7 +172,7 @@ func (c *Config) NewTransport() Transport { // it succesffully retrieves a new token, creates a new transport // authorized with it. func (c *Config) NewTransportWithCode(exchangeCode string) (Transport, error) { - token, err := c.Exchange(exchangeCode) + token, err := c.exchange(exchangeCode) if err != nil { return nil, err } @@ -186,22 +186,6 @@ func (c *Config) NewTransportWithCache(cache Cache) (Transport, error) { return NewAuthorizedTransportWithCache(c, cache) } -// Exchange exchanges the exchange code with the OAuth 2.0 provider -// to retrieve a new access token. -func (c *Config) Exchange(exchangeCode string) (*Token, error) { - token := &Token{} - err := c.updateToken(token, url.Values{ - "grant_type": {"authorization_code"}, - "redirect_uri": {c.opts.RedirectURL}, - "scope": {strings.Join(c.opts.Scopes, " ")}, - "code": {exchangeCode}, - }) - if err != nil { - return nil, err - } - return token, nil -} - // FetchToken retrieves a new access token and updates the existing token // with the newly fetched credentials. If existing token doesn't // contain a refresh token, it returns an error. @@ -240,6 +224,22 @@ func (c *Config) validate() error { return nil } +// Exchange exchanges the exchange code with the OAuth 2.0 provider +// to retrieve a new access token. +func (c *Config) exchange(exchangeCode string) (*Token, error) { + token := &Token{} + err := c.updateToken(token, url.Values{ + "grant_type": {"authorization_code"}, + "redirect_uri": {c.opts.RedirectURL}, + "scope": {strings.Join(c.opts.Scopes, " ")}, + "code": {exchangeCode}, + }) + if err != nil { + return nil, err + } + return token, nil +} + func (c *Config) updateToken(tok *Token, v url.Values) error { v.Set("client_id", c.opts.ClientID) v.Set("client_secret", c.opts.ClientSecret)