From 4c579cbd0d6d2b7377fc15d97e26c189cd7e694f Mon Sep 17 00:00:00 2001 From: Burcu Dogan Date: Mon, 11 Aug 2014 00:27:43 -0700 Subject: [PATCH] Export exchange. Allows users to exchange and retrieve a token without initialising a Transport. --- oauth2.go | 4 ++-- oauth2_test.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/oauth2.go b/oauth2.go index 09a104c..60aafdb 100644 --- a/oauth2.go +++ b/oauth2.go @@ -150,7 +150,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 } @@ -184,7 +184,7 @@ func (c *Config) validate() error { // 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) { +func (c *Config) Exchange(exchangeCode string) (*Token, error) { token := &Token{} vals := url.Values{ "grant_type": {"authorization_code"}, diff --git a/oauth2_test.go b/oauth2_test.go index b502b11..1b6a022 100644 --- a/oauth2_test.go +++ b/oauth2_test.go @@ -62,7 +62,7 @@ func TestExchangePayload(t *testing.T) { return nil, errors.New("no response") }, } - conf.exchange("exchange-code") + conf.Exchange("exchange-code") } func TestExchangingTransport(t *testing.T) {