From 32b8a902e6260d7afba2d10ed66149f83caeefd4 Mon Sep 17 00:00:00 2001 From: Burcu Dogan Date: Thu, 4 Sep 2014 12:03:06 -0700 Subject: [PATCH] client_secret should be optional. --- oauth2.go | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/oauth2.go b/oauth2.go index b6378b5..f757875 100644 --- a/oauth2.go +++ b/oauth2.go @@ -96,15 +96,14 @@ func NewConfig(opts *Options, authURL, tokenURL string) (*Config, error) { if err != nil { return nil, err } - conf := &Config{ + if opts.ClientID == "" { + return nil, errors.New("oauth2: missing client ID") + } + return &Config{ opts: opts, authURL: aURL, tokenURL: tURL, - } - if err = conf.validate(); err != nil { - return nil, err - } - return conf, nil + }, nil } // Config represents the configuration of an OAuth 2.0 consumer client. @@ -188,17 +187,6 @@ func (c *Config) FetchToken(existing *Token) (*Token, error) { }) } -// Checks if all required configuration fields have non-zero values. -func (c *Config) validate() error { - if c.opts.ClientID == "" { - return errors.New("oauth2: missing client ID") - } - if c.opts.ClientSecret == "" { - return errors.New("oauth2: missing client secret") - } - return nil -} - // Exchange exchanges the authorization code with the OAuth 2.0 provider // to retrieve a new access token. func (c *Config) Exchange(code string) (*Token, error) {