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 {
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) {