diff --git a/example_test.go b/example_test.go index d7afa38..59e80fe 100644 --- a/example_test.go +++ b/example_test.go @@ -31,15 +31,15 @@ func Example_config() { url := conf.AuthCodeURL("") fmt.Printf("Visit the URL for the auth dialog: %v", url) - // Use the exchange code that is handled by the redirect URL. + // Use the authorization code that is pushed to the redirect URL. // NewTransportWithCode will do the handshake to retrieve - // an access token and iniate a Transport that is - // authorized and authenticated the retrieved token. - var exchangeCode string - if _, err = fmt.Scan(&exchangeCode); err != nil { + // an access token and initiate a Transport that is + // authorized and authenticated by the retrieved token. + var authorizationCode string + if _, err = fmt.Scan(&authorizationCode); err != nil { log.Fatal(err) } - t, err := conf.NewTransportWithCode(exchangeCode) + t, err := conf.NewTransportWithCode(authorizationCode) if err != nil { log.Fatal(err) } diff --git a/oauth2.go b/oauth2.go index 7e179ed..8b3cb5e 100644 --- a/oauth2.go +++ b/oauth2.go @@ -154,12 +154,12 @@ func (c *Config) NewTransport() *Transport { return NewTransport(http.DefaultTransport, c, nil) } -// NewTransportWithCode exchanges the OAuth 2.0 exchange code with +// NewTransportWithCode exchanges the OAuth 2.0 authorization code with // the provider to fetch a new access token (and refresh token). Once // 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) +func (c *Config) NewTransportWithCode(code string) (*Transport, error) { + token, err := c.Exchange(code) if err != nil { return nil, err } @@ -191,13 +191,13 @@ func (c *Config) validate() error { return nil } -// Exchange exchanges the exchange code with the OAuth 2.0 provider +// Exchange exchanges the authorization 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(code string) (*Token, error) { vals := url.Values{ "grant_type": {"authorization_code"}, "client_secret": {c.opts.ClientSecret}, - "code": {exchangeCode}, + "code": {code}, } if len(c.opts.Scopes) != 0 { vals.Set("scope", strings.Join(c.opts.Scopes, " "))