1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Support both bearer + consumer tokens for Twitter modules

* Add support to both the twitter and twitterstats modules for authenticating using both bearer tokens as well as consumer key + secret.
  * A bearer token is defaulted to if it's supplied
  * Add this support to both the twitterstats module as well as to the existing twitter module, modifying its functionality to re-use the same HTTP client and handle authentication upfront via oauth2
This commit is contained in:
Casey Primozic
2019-10-29 03:15:57 -07:00
parent d82eda1933
commit a99af9a091
5 changed files with 64 additions and 32 deletions

View File

@@ -15,18 +15,22 @@ const (
type Settings struct {
common *cfg.Common
bearerToken string
count int
screenNames []interface{}
bearerToken string
consumerKey string
consumerSecret string
count int
screenNames []interface{}
}
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
settings := Settings{
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
bearerToken: ymlConfig.UString("bearerToken", os.Getenv("WTF_TWITTER_BEARER_TOKEN")),
count: ymlConfig.UInt("count", 5),
screenNames: ymlConfig.UList("screenName"),
bearerToken: ymlConfig.UString("bearerToken", os.Getenv("WTF_TWITTER_BEARER_TOKEN")),
consumerKey: ymlConfig.UString("consumerKey", os.Getenv("WTF_TWITTER_CONSUMER_KEY")),
consumerSecret: ymlConfig.UString("consumerSecret", os.Getenv("WTF_TWITTER_CONSUMER_SECRET")),
count: ymlConfig.UInt("count", 5),
screenNames: ymlConfig.UList("screenName"),
}
return &settings