client_secret should be optional.

This commit is contained in:
Burcu Dogan 2014-09-04 12:03:06 -07:00
parent cd4a6ded37
commit 32b8a902e6

View File

@ -96,15 +96,14 @@ func NewConfig(opts *Options, authURL, tokenURL string) (*Config, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
conf := &Config{ if opts.ClientID == "" {
return nil, errors.New("oauth2: missing client ID")
}
return &Config{
opts: opts, opts: opts,
authURL: aURL, authURL: aURL,
tokenURL: tURL, tokenURL: tURL,
} }, nil
if err = conf.validate(); err != nil {
return nil, err
}
return conf, nil
} }
// Config represents the configuration of an OAuth 2.0 consumer client. // 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 // Exchange exchanges the authorization code with the OAuth 2.0 provider
// to retrieve a new access token. // to retrieve a new access token.
func (c *Config) Exchange(code string) (*Token, error) { func (c *Config) Exchange(code string) (*Token, error) {