diff --git a/README.md b/README.md
index cd81aa8..92259d0 100644
--- a/README.md
+++ b/README.md
@@ -52,8 +52,6 @@ To do this, you will need to setup the following environment variables:
- GITHUB_ACCESS_TOKEN
- TWITTER_CONSUMER_KEY
- TWITTER_CONSUMER_SECRET
-- TWITTER_ACCESS_TOKEN
-- TWITTER_ACCESS_SECRET
If you want the content to be publish in a README file on a repo, you also need these variables
- GITHUB_PUBLISH_REPO_OWNER (Your Github username)
@@ -82,7 +80,7 @@ _NOTE: The key is used in the --provider or --pr option_
| Name | Key | Environment Variables | Observation |
|--------------|:-------:|----------------------| -------------|
-| Twitter | twitter | TWITTER_CONSUMER_KEY
TWITTER_CONSUMER_SECRET
TWITTER_ACCESS_TOKEN
TWITTER_ACCESS_SECRET | |
+| Twitter | twitter | TWITTER_CONSUMER_KEY
TWITTER_CONSUMER_SECRET | |
| Github | github | GITHUB_PUBLISH_REPO_OWNER
GITHUB_PUBLISH_REPO_NAME
GITHUB_PUBLISH_REPO_FILE | For now it is only going to be posted in the README file and the repository must be **public** |
_NOTE: The key is used in the --publisher or --pub option_
diff --git a/cmd/larry/main.go b/cmd/larry/main.go
index 39cb259..7436fb0 100644
--- a/cmd/larry/main.go
+++ b/cmd/larry/main.go
@@ -29,8 +29,6 @@ var (
twitterConsumerKey = envString("TWITTER_CONSUMER_KEY", "")
twitterConsumerSecret = envString("TWITTER_CONSUMER_SECRET", "")
- twitterAccessToken = envString("TWITTER_ACCESS_TOKEN", "")
- twitterAccessSecret = envString("TWITTER_ACCESS_SECRET", "")
)
func main() {
@@ -113,8 +111,6 @@ func getPublishers(cfg config.Config) (map[string]larry.Publisher, error) {
accessKeys := twitter.AccessKeys{
TwitterConsumerKey: twitterConsumerKey,
TwitterConsumerSecret: twitterConsumerSecret,
- TwitterAccessToken: twitterAccessToken,
- TwitterAccessSecret: twitterAccessSecret,
}
pubs[v] = twitter.NewPublisher(accessKeys, cfg)
} else if v == publisher.Github {
diff --git a/publisher/twitter/publisher.go b/publisher/twitter/publisher.go
index 7beeae7..0dc1c18 100644
--- a/publisher/twitter/publisher.go
+++ b/publisher/twitter/publisher.go
@@ -1,14 +1,15 @@
package twitter
import (
+ "context"
"fmt"
"log"
"strings"
"github.com/dghubble/go-twitter/twitter"
- "github.com/dghubble/oauth1"
"github.com/ezeoleaf/larry/config"
"github.com/ezeoleaf/larry/domain"
+ "golang.org/x/oauth2/clientcredentials"
)
// Publisher represents the publisher client
@@ -21,18 +22,19 @@ type Publisher struct {
type AccessKeys struct {
TwitterConsumerKey string
TwitterConsumerSecret string
- TwitterAccessToken string
- TwitterAccessSecret string
}
// NewPublisher returns a new publisher
func NewPublisher(accessKeys AccessKeys, cfg config.Config) Publisher {
log.Print("New Twitter Publisher")
- oauthCfg := oauth1.NewConfig(accessKeys.TwitterConsumerKey, accessKeys.TwitterConsumerSecret)
- oauthToken := oauth1.NewToken(accessKeys.TwitterAccessToken, accessKeys.TwitterAccessSecret)
+ config := &clientcredentials.Config{
+ ClientID: accessKeys.TwitterConsumerKey,
+ ClientSecret: accessKeys.TwitterConsumerSecret,
+ TokenURL: "https://api.twitter.com/oauth2/token",
+ }
- client := twitter.NewClient(oauthCfg.Client(oauth1.NoContext, oauthToken))
+ client := twitter.NewClient(config.Client(context.Background()))
p := Publisher{
Config: cfg,