Skip to content

Commit

Permalink
adding bearer token in for twitter client
Browse files Browse the repository at this point in the history
  • Loading branch information
stat committed Nov 15, 2024
1 parent 09994f5 commit e8a9ee1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions twitter-langchain/twitter_langchain/twitter_api_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,32 @@ def validate_environment(cls, values: dict) -> Any:
api_key = get_from_dict_or_env(values, "twitter_api_key", "TWITTER_API_KEY")
api_secret = get_from_dict_or_env(values, "twitter_api_secret", "TWITTER_API_SECRET")
access_token = get_from_dict_or_env(values, "twitter_access_token", "TWITTER_ACCESS_TOKEN")
access_token_secret = get_from_dict_or_env(
values, "twitter_access_token_secret", "TWITTER_ACCESS_TOKEN_SECRET"
)
access_token_secret = get_from_dict_or_env(values, "twitter_access_token_secret", "TWITTER_ACCESS_TOKEN_SECRET")
bearer_token = get_from_dict_or_env(values, "twitter_bearer_token", "TWITTER_BEARER_TOKEN")

try:
import tweepy
except Exception:
raise ImportError(
"Tweepy Twitter SDK is not installed. "

"Please install it with `pip install tweepy`"
"Please install it with `pip install tweepy`"
) from None

client = tweepy.Client(
consumer_key=api_key,
consumer_secret=api_secret,
access_token=access_token,
access_token_secret=access_token_secret,
bearer_token=bearer_token,
)

values["client"] = client
values["api_key"] = api_key
values["api_secret"] = api_secret
values["access_token"] = access_token
values["access_token_secret"] = access_token_secret
values["bearer_token"] = bearer_token

return values

Expand Down

0 comments on commit e8a9ee1

Please sign in to comment.